Skip to main content
edited tags
Link
TheMaster
  • 51.6k
  • 7
  • 76
  • 102
[Edit removed during grace period]
Link
nbro
  • 16.1k
  • 34
  • 122
  • 219
Unnecessary info/details removed.
Source Link
nbro
  • 16.1k
  • 34
  • 122
  • 219

Difference What is the difference between float and double?

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?

Difference between float and double

I know, I've read about the difference between double precision and single precision, etc. But they should give the same results on 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 again and again, until I found that using float is not the same using double. 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 correctly.

I repeat, the output was the SAME, the results were the SAME, but putting float didn't work - only double. The values were not so big too, and the program gave the same results on the same tests both with float and double, but the online judge accepted only the double-provided solution.

Why? What is the difference?

What is the difference between float and double?

I've read about the difference between double precision and single precision. However, in most cases, float and double seem to be interchangeable, i.e. using one or the other does not seem to affect the results. Is this really the case? When are floats and doubles interchangeable? What are the differences between them?

Question Protected by user207421
In English, the subjective form of the singular first-person pronoun, "I", is capitalized, along with all its contractions such as I'll and I'm.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134
Loading
edited tags
Link
mskfisher
  • 3.4k
  • 4
  • 37
  • 50
Loading
Source Link
VaioIsBorn
  • 7.9k
  • 9
  • 33
  • 29
Loading