This commit is contained in:
ceriel 1988-08-10 10:41:15 +00:00
parent bb46f5218c
commit a1032b168c

View file

@ -46,6 +46,7 @@ cvt(value, ndigit, decpt, sign, ecvtflag)
if (ndigit < 0) ndigit = 0; if (ndigit < 0) ndigit = 0;
if (ndigit > NDIGITS) ndigit = NDIGITS; if (ndigit > NDIGITS) ndigit = NDIGITS;
pe = &buf[ndigit]; pe = &buf[ndigit];
buf[0] = '\0';
*sign = 0; *sign = 0;
if (value < 0) { if (value < 0) {
@ -83,6 +84,7 @@ cvt(value, ndigit, decpt, sign, ecvtflag)
*p++ = (int)value + '0'; *p++ = (int)value + '0';
value = 10.0 * (value - (int)value); value = 10.0 * (value - (int)value);
} }
if (pe >= buf) {
p = pe; p = pe;
*p += 5; /* round of at the end */ *p += 5; /* round of at the end */
while (*p > '9') { while (*p > '9') {
@ -101,6 +103,7 @@ cvt(value, ndigit, decpt, sign, ecvtflag)
} }
} }
*pe = '\0'; *pe = '\0';
}
return buf; return buf;
} }
#endif #endif