Bug 3202 – std.math.pow cause dead loop

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-07-21T21:28:00Z
Last change time
2015-06-09T01:28:06Z
Assigned to
bugzilla
Creator
rinick

Comments

Comment #0 by rinick — 2009-07-21T21:28:35Z
the case is: pow(1.01, int.min); because int.min == -int.min Maybe the while loop should be put into pow(F, uint) instead of pow(F, int) like the following: pure nothrow F pow(F)(F x, int n) { if (n < 0) { return 1 / pow(x, cast(uint)(-n)); } return pow(x, cast(uint)n); }
Comment #1 by rinick — 2009-07-21T22:54:26Z
(In reply to comment #0) > Maybe the while loop should be put into pow(F, uint) instead of pow(F, int) > like the following: what about: pure nothrow F pow(F)(F x, int n) if (isFloatingPoint!(F)) { if (n < 0) return 1 / pow(x, cast(uint)(-n)); else return pow(x, cast(uint)n); } pure nothrow F pow(F)(F x, uint n) // allow integer if n is uint { ... } This also solve #2973
Comment #2 by bugzilla — 2010-06-22T00:14:42Z
Comment #3 by bugzilla — 2010-08-11T02:43:44Z
Fixed DMD 2.048