lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2018-06-05 6:34 GMT+02:00 Albert Chan <albertmcchan@yahoo.com>:
>
>>> On Jun 4, 2018, at 9:40 PM, KHMan <keinhong@gmail.com> wrote:
>>>
>>> On 6/5/2018 8:33 AM, Albert Chan wrote:
>>>
>>> For 53 bits double, to make same math result across platform,
>>> maybe add this to Lua.c ? (even if not needed)
>>> fesetenv (FE_PC53_ENV);
>>
>> Wrong, Lua coders should instead strive to have a modicum level of competency in floating-point arithmetic and floating-point implementations.
>>
>> If someone insist on _PERFECTION_ for their floating-point output, then IMHO the onus is on that someone to do (and maintain) the necessary tweaks (and test regime) for that purpose.
...
>> I really do not think suppliers of programming language implementations should be hand-holding or babysitting users who want perfection down to the very last ULP. Those users are cordially invited to do it on their own time and dime.
>>

I agree 100% with KHMan. Floating-point really is not, and never has
been, a topic easily handled by non-specialists. You can't expect the
designer of a subroutine library written in C (even if disguised as a
scripting language) to fix whatever the authors of the C compiler did
not.

Nicholas Higham's book "Accuracy and Stability of Numerical
Algorithms" https://epubs.siam.org/doi/book/10.1137/1.9780898718027
devotes 663 pages to the topic.

> Some algorithm *required* getting the last ULP right.
>
> Example: https://github.com/achan001/fsum
>
> fsum.lua use Shewchuk Algorithm to get *exact* sum of numbers.
> If ask for total, it returned the correctly rounded 53-bit double.
> It simply will not work with extended precision rounding.
>
> I had to patch Lua.c to make it work.

That sort of thing is way above what you can expect from Lua. Why,
they even dropped the inverse hyperbolic functions from Lua 5.3 so
that the world can see that Lua is not specialized mathematical
software.

The fact that you know Shewchuk's Algorithm, and can make that patch,
proves that you are an expert. Don't be a bumptious expert.