floating point - Why do I see a double variable initialized to some value like 21.4 as 21.399999618530273? -


double r = 11.631; double theta = 21.4; 

in debugger, these shown 11.631000000000000 , 21.399999618530273.

how can avoid this?

these accuracy problems due internal representation of floating point numbers , there's not can avoid it.

by way, printing these values @ run-time still leads correct results, @ least using modern c++ compilers. operations, isn't of issue.


Comments

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

java - What is the equivalent of @Value in CDI world? -