Thread overview
[Issue 15365] std.math: 80-bit exp() tests are utterly wrong when returning subnormals
Nov 19, 2015
Iain Buclaw
Nov 20, 2015
Don
Nov 20, 2015
Iain Buclaw
Nov 22, 2015
Iain Buclaw
[Issue 15365] std.math: 80-bit exp() tests are marginally wrong when returning subnormals
Dec 12, 2017
Iain Buclaw
Dec 17, 2022
Iain Buclaw
November 19, 2015
https://issues.dlang.org/show_bug.cgi?id=15365

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org
           Severity|enhancement                 |major

--
November 20, 2015
https://issues.dlang.org/show_bug.cgi?id=15365

--- Comment #1 from Don <clugdbug@yahoo.com.au> ---
Note that these errors occur only in the slow path of the asm exp(). Thus, a more accurate, slower calculation can be added with no impact on speed.

Clearly, there is a loss of precision bug. I am not certain, but the problem
may be in the extraction of the integer part, which is obviously limited to 64
bits.
I need to look into this.

This title of this bug report is a bit alarmist though, it's not very generous to describe 52 bit accurate as "utterly wrong". :)

--
November 20, 2015
https://issues.dlang.org/show_bug.cgi?id=15365

--- Comment #2 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Don from comment #1)
> Note that these errors occur only in the slow path of the asm exp(). Thus, a more accurate, slower calculation can be added with no impact on speed.
> 
> Clearly, there is a loss of precision bug. I am not certain, but the problem
> may be in the extraction of the integer part, which is obviously limited to
> 64 bits.
> I need to look into this.
> 
> This title of this bug report is a bit alarmist though, it's not very generous to describe 52 bit accurate as "utterly wrong". :)

What about 5 bit accuracy? :-P

--
November 22, 2015
https://issues.dlang.org/show_bug.cgi?id=15365

--- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> ---
Stepped through the path dmd code uses for exp().

(1) 0x1.1p13L       - Uses L_normal path
(2) -0x1.18p+13L    - Uses L_normal path
(3) -0x1.625p+13L   - Uses L_normal path
(4) -0x1.62dafp+13L - Uses L_normal path

Interestingly, the last test exp(-11398) uses the L_subnormal path, and returns results that are correct to wolfram in at least the bits that can be represented.

Also tried exp(-11370) and exp(-11387.4), and on the surface it looks like any
near underflow/subnormal that represents a decimal will only be correct up to
double precision.

Also tested the first iteration of exp() and it returns the same results.

--
December 12, 2017
https://issues.dlang.org/show_bug.cgi?id=15365

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.math: 80-bit exp()      |std.math: 80-bit exp()
                   |tests are utterly wrong     |tests are marginally wrong
                   |when returning subnormals   |when returning subnormals

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15365

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--