Temporary patch for bug 1358192: printf("%f"...) sets fraction to zero.
[fw/sdcc] / device / lib / printf_large.c
index e087f64d95f3873336d00b01c3ddda5fda90ba5d..e0a24ab7eea50816de9b7d10d6217f0eaee76e66 100644 (file)
@@ -211,7 +211,7 @@ static int output_float (float f, unsigned char reqWidth,
 
   // split the float
   integerPart=f;
-  decimalPart=f-integerPart;
+  decimalPart=f-(float)integerPart;
 
   // fill the buffer with the integerPart (in reversed order!)
   while (integerPart) {
@@ -235,7 +235,7 @@ static int output_float (float f, unsigned char reqWidth,
       // truncate the float
       integerPart=decimalPart;
       fpBuffer[fpBD++]='0' + integerPart;
-      decimalPart-=integerPart;
+      decimalPart-=(float)integerPart;
     } while (--i);
   }