The value of d which is a double when compared to 0.01 is not satisfied due to presence of some digits at the end of the number which I found using flags . Why does this occur and how do we overcome this ? Thank you . Code for this : https://i.stack.imgur.com/06I81.png
Asked
Active
Viewed 92 times
-2
-
3Please don't post code-images. Post your actual code and output here. – Maroun Jun 08 '15 at 08:35
-
1[What every computer scientist should know about floating-point arithmetic](http://www.cse.msu.edu/~cse320/Documents/FloatingPoint.pdf) – BlackDwarf Jun 08 '15 at 08:36
-
Please read about IEEE floating point representations. `0.1` is not exactly representable as a floating point number in binary representation. A long version is [here](http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html), a shorter one [here](http://floating-point-gui.de/basic/). – Axel Jun 08 '15 at 08:40