Number Bug

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderator: Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Number Bug

Post by dunbarx » Tue Jan 04, 2022 3:40 pm

Richmond.

SANE was "Standard Apple Numeric Environment" and was replaced decades ago. What is running today, however, still has the same limitation.

There are websites that will do that sort of math for you. They prove that HC or LC fails after digit 17 or so.

Craig

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Number Bug

Post by SparkOut » Tue Jan 04, 2022 8:50 pm

The bug report I linked on the previous page wrote:LiveCode uses 64-bit IEEE 754 floating-point representation for numbers. This provides around 16 digits of decimal precision [...]
The precision of the calculation [...] is exactly as defined by the LiveCode language specification and the IEEE 754 standard.
This is more a historical limitation defined by "computer scientists" and "standards" than a failing of LiveCode programmers to implement mathematics properly. While it would be good to have native bigNum arithmetic in the engine, to have all calculations use arbitrarily large digits would be a vast loss in the trade-off between precision and efficiency.
You don't usually need such as 1.0000000000 + 1.0000000000 = 2.0000000000
If you do need that precision, there are ways to use it.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Number Bug

Post by dunbarx » Tue Jan 04, 2022 9:57 pm

What Sparkout said.

If you are an astronaut trying to find your way around, see the above post about galaxies. If you want to design very closely fit machine parts, know that 16 digits will give you accuracy to about the width of a proton.

The limit is not a, er, limit to practical use. For number munchers, we have Hermann's gadgetry.

Craig

Post Reply