bug-gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gforth] [bug #50221] FP operations produce unexpected NaNs


From: anonymous
Subject: [Bug-gforth] [bug #50221] FP operations produce unexpected NaNs
Date: Sun, 5 Feb 2017 14:11:52 +0000 (UTC)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8

Follow-up Comment #4, bug #50221 (project gforth):

So, a possible fix would be (in engine/ecvt_r.c):
..
   *exp=(x==0)?-1:(int)floor(log10(x));
   if(*exp < -300) { /* maybe a denormal: do this in two steps */
     x = x * pow10(300.);
     x = x / pow10((double)(*exp)+300.);
   } else {
     x = x / pow10((double)*exp);
   }
   
+   // Adjust x and exp in case rounding grew x a digit (e.g.: 0.999999999..
-> 1.0)
+   if(x>=10.) {
+     x /= 10.;
+     exp += 1; 
+   }
   


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?50221>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]