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/


_______________________________________________
bug-gforth mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-gforth

Reply via email to