www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3202] New: std.math.pow cause dead loop

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3202

           Summary: std.math.pow cause dead loop
           Product: D
           Version: 2.031
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: rinick gmail.com


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);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 21 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3202





--- Comment #1 from ZHOU Zhenyu <rinick gmail.com>  2009-07-21 22:54:26 PDT ---
(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 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 21 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3202


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 11 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3202


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla kyllingen.net
         AssignedTo|andrei metalanguage.com     |bugzilla kyllingen.net


--- Comment #2 from Lars T. Kyllingstad <bugzilla kyllingen.net> 2010-06-22
00:14:42 PDT ---
http://www.dsource.org/projects/phobos/changeset/1677

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3202


ZY Zhou <rinick gmail.com> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3202



--- Comment #3 from Lars T. Kyllingstad <bugzilla kyllingen.net> 2010-08-11
02:43:44 PDT ---
Fixed DMD 2.048

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2010