[Issue 356] New: std, math.tan doesn't preserve NaN payloads [fix included]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 20 05:27:14 PDT 2006


http://d.puremagic.com/issues/show_bug.cgi?id=356

           Summary: std,math.tan doesn't preserve NaN payloads [fix
                    included]
           Product: D
           Version: 0.167
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: minor
          Priority: P1
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: clugdbug at yahoo.com.au


Currently in tan(x), it effectively does 
  if (isnan(x)) return real.nan; 
when it should be
  if (isnan(x)) return x;

The good news is that all math functions preserve NaN payloads, with this one
exception. And it's a one-line fix.
In the asm code for tan, at the end of the code, add the line "jnp Lret".

-------
trigerr:
    jnp Lret            ; // if x is NaN, return x.   <<< ADD THIS LINE
    fstp    ST(0)       ; // dump x, which will be infinity
    }
    return real.nan;

Lret:
    ;
}
---------

Also, tan() currently fails one if its unit tests ( tan(1e100)). Since the
isnan(tan(1e100)) is not correct mathematically, I think that line should just
be removed.
--------
            // overflow
            [   real.infinity,  real.nan],
            [   real.nan,       real.nan],
            [   1e+100,         real.nan], <<< REMOVE THIS LINE
    ];
--------


-- 




More information about the Digitalmars-d-bugs mailing list