I know, I've read about the difference between double precision and single precision, etc. But they should give the same results onHowever, in most cases right?
I was solving a problem on a programming contest and there were calculations with floating point numbers that were not really big, so I decided to use float instead of double, and I checked it - I was getting the correct results. But when I send the solution, it said only 1 of 10 tests was correct. I checked againfloat and againdouble seem to be interchangeable, until I found that using float is not the same using doublei. I put double for the calculations and double for the output, and the program gave the SAME results, but this time it passed all the 10 tests correctlye.
I repeat, the output was the SAME, the results were using one or the SAME, but putting float didn't work - only double. The values wereother does not so big too, and the program gaveseem to affect the same results on. Is this really the same tests both with floatcase? When are floats and double, but the online judge accepted only the double-provided solution.
Whydoubles interchangeable? What isare the differencedifferences between them?