Menu

#695 (machar()).eps() wrong on i386

v1.0 (example)
closed
nobody
None
5
2018-04-07
2016-04-22
No

On a i386 CPU, the single precision "EPS" is wrongly calculated:

GDL> print, (machar(double=0)).eps
  1.08420e-19
GDL> print, (machar(double=1)).eps
   1.0842022e-19

When I do the same on a x86_64 machine, I get:

GDL> print, (machar(double=0)).eps
  1.19209e-07
GDL> print, (machar(double=1)).eps
   2.2204460e-16

Since the value (for double=0) is used as stepwidth in mpfit, mpfit fails on i386.
Interestingly, on another 32-bit platform (armhf), the value is correct:

GDL> print, (machar(double=0)).eps
  1.19209e-07
GDL> print, (machar(double=1)).eps
   2.2204460e-16

Discussion

  • giloo

    giloo - 2016-05-17

    Hi Ole,
    GDL implements (or is supposed to) this code . There are no apparent errors. I wonder what the above code gives on a i386?

     
  • Alain C.

    Alain C. - 2016-05-18

    I was able to replicate the bug on an old laptop (Ubuntu) and a VM in Debian 32b

    yes, the current GDL code used a rather tricky way to compute that.

    I made a few search and it seems that current C++ compilers do provide
    interessting (simple) solutions but I had no time to test is.
    http://www.cplusplus.com/reference/limits/numeric_limits/

     
  • Sylwester Arabas

    • status: open --> closed
     

Log in to post a comment.