Forums Register Login

double and float loosing precision - java core knowledge

+Pie Number of slices to send: Send
Hello,



The output of this program is:

50.12333
0.12333000000000283
float ----------------------
50.12333
0.12332916


Can anyone explain these values? I would expect no loss of precision with such small values!
+Pie Number of slices to send: Send
value doesn't matter when you're dealing with floating point arithmetic. There's no magical number after which suddenly you start to loose precision, no magic formula that will tell you if and if so how much precision will be lost at any point.

http://docs.sun.com/source/806-3568/ncg_goldberg.html
Grow your own food... or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 863 times.
Similar Threads
float * double...newbie question
Keyboard.Class/Anyone with brains.pt2
Precision and scale of a decimal value
iterating a double
Problem with DecimalFormat
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:47:34.