digitalmars.D.bugs - [Issue 356] New: std,math.tan doesn't preserve NaN payloads [fix included]
- d-bugmail puremagic.com (41/41) Sep 20 2006 http://d.puremagic.com/issues/show_bug.cgi?id=356
- Don Clugston (9/32) Sep 25 2006 I spoke too soon. The version(linux) form of pow() should have two lines...
- d-bugmail puremagic.com (9/9) Oct 04 2006 http://d.puremagic.com/issues/show_bug.cgi?id=356
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 ]; -------- --
Sep 20 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;" <<<<<<
Sep 25 2006
http://d.puremagic.com/issues/show_bug.cgi?id=356 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Fixed DMD 0.168 --
Oct 04 2006