+ 1
(0.7 >a) return true , can you explain why ?
5 Respostas
+ 1
You got the answer then plzz show🙂🙂🙂
+ 6
0.7 is a double value. Putting it in a float losses precision so the float ends up smaller. Your best practice for dealing with real numbers is use double as your type. Also, it doesn't hurt to use a tiny range for comparisons. If (a > 0.69999 && a < 0.70001) works better than if (a == 0.7).
+ 4
Due to something like 0.699999999999 > 0.69999. The number of decimal places I used isn't exact but just to give you a general idea.
+ 1
Thank you sir .
+ 1
Program needs to convert this:
0.7
into binary:
0.10111111111111111...
You can not write up the decimal expansion of 0.7 in binary. It has similar problem than trying to divide 1 with 3.
When program writes it from the binary back to 0.7, it has a small throw.