java - Double parseDouble adding extra 0's when adding the numbers -
i running weird situation. counting numbers using double parsedouble. in situation getting 0's instance instead of 109.1 getting ... 109.10000001.
i trying add string json.
here line of code executing.
points = points + double.parsedouble(x.points);
java uses ieee floating point numbers double
(and float
) datatypes. double
has lot of precision, not infinite precision. numbers approximated.
in addition (no pun intended), adding numbers compounds floating point errors. error large enough notice, such issue here.
if can accept performance hit, use bigdecimal
, arbitrary precision.
Comments
Post a Comment