[REBOL] Re: decimal woes
From: g:santilli:tiscalinet:it at: 19-Jul-2003 15:32
Hi Maxim,
On Friday, July 18, 2003, 7:28:06 PM, you wrote:
MOA> Do you think this means that print and probe do not contain
MOA> all digits of the internal hw decimal value?
Of course they don't. The internal representation is binary, while
they print in decimal. There's no point in showing an amount that
is lower than the error caused by the internal representation.
However, since you use repeated additions, this error sums up and
becomes "visible", i.e. big enough that PRINT thinks it is worth
showing.
In your case, fixed point arithmetic is probably the best
solution. If you want to use floating point, you have to take the
error into account. Or, at least you have to avoid operations that
can make the error grow, as in:
i: 0
loop 50 [
probe time: 2 * i / 100
i: i + 1
]
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/