Thread overview
[Issue 356] New: std,math.tan doesn't preserve NaN payloads [fix included]
Sep 20, 2006
d-bugmail
Sep 25, 2006
Don Clugston
Oct 05, 2006
d-bugmail
September 20, 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@digitalmars.com
        ReportedBy: clugdbug@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
    ];
--------


-- 

September 25, 2006
d-bugmail@puremagic.com wrote:
> 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@digitalmars.com
>         ReportedBy: clugdbug@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.

I spoke too soon. The version(linux) form of pow() should have two lines changed:

    if (isnan(y))
        return y;   //  <<< instead of "return real.nan" <<<<<<<<

    if (y == 0)
        return 1;       // even if x is $(NAN)
    if (isnan(x) && y != 0)
        return x; // instead of "return real.nan;"  <<<<<<
October 05, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=356


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla@digitalmars.com  2006-10-04 20:00 -------
Fixed DMD 0.168


--