# Float vs Double - Help

In 186B - Growing Mushrooms, Why does a solution with float 119775360 fails while a solution with double 119774888 passes- when we need only 2 digits after the decimal points?

The solution with float fails on 10th testcase where it gives -
`wrong answer 2nd words differ - expected: '867788.40', found: '867788.38'`

Isn’t double useful only when we need a lot of digits after the decimal point?

Double helps you to get more accurate value after some operation

1 Like

As we know Double is twice as precision than float.
As you said Expected Value is 867788.40
Try using round() function on float.It might work…

1 Like

i don’t think using round() would be a great idea as the solution passes with double and not with float meaning we need to be more accurate

what is probably happening here is before getting to the ans in the other operations float gives more accurate ans which prbly resulted in the 0.02 diff

1 Like

double has 15 decimal digits of precision.
and
float has 7 decimal digits of precision.

so though you are using `fixed` and `precision(2)` for the output value, for float its getting rounded of till 7 digits only whereas for double its checking till 15 digits.
Hope it helps

1 Like