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
Post a Comment