Re: I Need Help
- Posted by Michael Bolin <michaeltom at GEOCITIES.COM> Jun 21, 1997
- 936 views
> There's a simple explanation for why you aren't getting the > results that you expect. The root of the problem is > that 0.1 cannot be represented in binary floating-point > form *exactly*. This means that if you add up ten 0.1's > you will *not* get 1. > > Try the following statement in Euphoria: > ? .1 + .1 + .1 + .1 + .1 + .1 + .1 + .1 + .1 + .1 - 1 > > You will not get 0. You will get -1.11e-016. > in other words a very very small number. Here is a routine that will correct such errors up to 15 decimal places: function round(atom x) return floor(x*1e15+0.5)/1e15 end function Maybe this will be useful to someone. Regards, Michael Bolin