From: ceriel Date: Thu, 22 Oct 1987 13:58:48 +0000 (+0000) Subject: replace 10 by 10.0, so that the conversion is not done at runtime X-Git-Tag: release-5-5~3789 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b75744f0d4bf69e0e32729c03bfce9c0d2a70eae;p=ack.git replace 10 by 10.0, so that the conversion is not done at runtime --- diff --git a/lang/cem/libcc/gen/ecvt.c b/lang/cem/libcc/gen/ecvt.c index 84ca9f36b..43a0bf95d 100644 --- a/lang/cem/libcc/gen/ecvt.c +++ b/lang/cem/libcc/gen/ecvt.c @@ -26,8 +26,8 @@ cvt(value, ndigit, decpt, sign, ecvtflag) int ndigit, *decpt, *sign; { double intpart, fractpart; - static char buf[NDIGITS]; - char buf1[NDIGITS]; + static char buf[NDIGITS+1]; + char buf1[NDIGITS+1]; register char *pe = buf1; register char *pb; int pointpos = 0; @@ -47,7 +47,7 @@ cvt(value, ndigit, decpt, sign, ecvtflag) do { /* get digits of integer part, low order digit first */ - value = modf(intpart/10, &intpart); + value = modf(intpart/10.0, &intpart); /* compensate for rounding errors, because the conversion to "int" truncates */ @@ -56,7 +56,7 @@ cvt(value, ndigit, decpt, sign, ecvtflag) pe = &buf1[0]; while (pb < &buf1[NDIGITS]) *pe++ = *pb++; } - *pe++ = (int)((value+.05) * 10) + '0'; + *pe++ = (int)((value+.05) * 10.0) + '0'; pointpos++; } while (intpart != 0); pb = buf; @@ -66,7 +66,7 @@ cvt(value, ndigit, decpt, sign, ecvtflag) pb = &buf[0]; if (value > 0) { fractpart = value; - while ((value = value*10) < 1) { + while ((value = value*10.0) < 1) { fractpart = value; pointpos--; } @@ -85,7 +85,7 @@ cvt(value, ndigit, decpt, sign, ecvtflag) if (pe > &buf[NDIGITS]) pe = &buf[NDIGITS]; } while (pb <= pe) { - fractpart = modf(fractpart * 10, &value); + fractpart = modf(fractpart * 10.0, &value); *pb++ = (int)value + '0'; } pb = pe;