www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15365] New: std.math: 80-bit exp() tests are utterly wrong


          Issue ID: 15365
           Summary: std.math: 80-bit exp() tests are utterly wrong when
                    returning subnormals
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

When comparing the DMD-style inline assembler path vs. the generic cephes
implementation, observed the following.

These test points:

[ 0x1.1p+13L,     0x1.29aeffefc8ec645p+12557L  ], // near overflow

feqrel(cephes, iasm) = 52
feqrel(iasm, wolfram) = 52
feqrel(cephes, wolfram) = 64


[-0x1.18p+13L,    0x1.5e4bf54b4806db9p-12927L  ], // near underflow

feqrel(cephes, iasm) = 51
feqrel(iasm, wolfram) = 51
feqrel(cephes, wolfram) = 64


[-0x1.625p+13L,   0x1.a6bd68a39d11f35cp-16358L ], // ditto

feqrel(cephes, iasm) = 53
feqrel(iasm, wolfram) = 53
feqrel(cephes, wolfram) = 64


[-0x1.62dafp+13L, 0x1.96c53d30277021dp-16383L  ], // near underflow - subnormal

feqrel(cephes, iasm) = 54
feqrel(iasm, wolfram) = 5
feqrel(cephes, wolfram) = 5


In (1), (2), and (3) the generic version is more accurate than the IASM
version, matching bit-for-bit the result given from wolfram.

What is interesting is that in each case, they share up to double precision in
common.  This suggests that whatever the IASM branch does (I assume this
happens in L_subnormal) it truncates or rounds the value to double.

Test (4) is simply way off the mark for both IASM and generic, and should
probably be scrapped as it's clear we can't guarantee any reasonable level of
accuracy with any lower number.  If I understand the documentation correctly,
the domain that the exp() function has been tested with is +-10000.

Nov 19 2015