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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -