BOOL left, BOOL zero, BOOL sign, BOOL space)
#endif
{
- char negative=0;
+ BOOL negative=0;
unsigned long integerPart;
float decimalPart;
char fpBuffer[128];
// split the float
integerPart=f;
- decimalPart=f-(float)integerPart;
+ decimalPart=f-integerPart;
// fill the buffer with the integerPart (in reversed order!)
while (integerPart) {
// fill buffer with the decimalPart (in normal order)
fpBD=fpBI;
- if (i=reqDecimals /* that's an assignment */) {
- do {
+
+ for (i=reqDecimals; i>1; i--) {
decimalPart *= 10.0;
// truncate the float
integerPart=decimalPart;
fpBuffer[fpBD++]='0' + integerPart;
- decimalPart-=(float)integerPart;
- } while (--i);
+ decimalPart-=integerPart;
+ }
+ if (i) {
+ decimalPart *= 10.0;
+ // truncate the float
+ integerPart = decimalPart + 0.5;
+ fpBuffer[fpBD++] = '0' + integerPart;
}
minWidth=fpBI; // we need at least these