Re: BUG! Erratic for loop behavior
- Posted by petelomax at blueyonder.co.uk Mar 25, 2002
- 449 views
On Mon, 25 Mar 2002 11:04:25 +1000, dm31 at uow.edu.au wrote: >an example is the 0.1 is stored as 1 x 10^-1 >thus the mantissa is 1 and the exponent is -1 >so using a 8-bit float as an example 0.1 in binary is > >0001 and 1111(-1 in 2's complement) > >So storing numbers like 0.1, 0.3 and 0.01 completely accurately should >not be a problem. It is only a problem in 'larger' decimal numbers. > >for i = 31.4 to 31.5 do... should work perfectly. Or am I just been >dumb? Possibly the latter IEEE 754 floating point numbers are held in binary math, ie <sign>*<mantissa>*2^<exponent>. Yes, that's powers of 2, not 10. This means that 0.1 *CANNOT* be held, the closest you get is about 0.100000000149 Read all about the only alternative I've found at http://www2.hursley.ibm.com/decimal/ Pete