Strange math behaviour... could someone explain this ?

Ken Ray kray at sonsothunder.com
Sun Oct 9 13:00:50 EDT 2005


On 10/9/05 7:41 AM, "Mark Waddingham" <36degrees at runrev.com> wrote:

> Floating-point arithmetic (which Revolution uses) works entirely in base
> 2. However, while all decimal integers have an accurate representation
> in binary, not all decimal fractions do and this is where the
> approximation error comes from.
> 
> For example:
>  1/8 = 0.125 (decimal) and 0.001 (binary)
> But
>  1/5 = 0.2 (decimal) and 0.0011001100110011... (binary)
> Note that the binary representation of 1/5 is a recurring fraction and
> as such admits no finite (non-rational) representation.

Thanks for that explanation, Mark! It makes sense to me now...

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list