}
static LDOUBLE
-pow10(int exp)
+pow10(int in_exp)
{
LDOUBLE result = 1;
- while (exp) {
+ while (in_exp) {
result *= 10;
- exp--;
+ in_exp--;
}
return result;
}
int caps = 0;
long intpart;
long fracpart;
+ long max10;
if (max < 0)
max = 6;
/* we "cheat" by converting the fractional part to integer by
multiplying by a factor of 10 */
- fracpart = roundv((pow10(max)) * (ufvalue - intpart));
+ max10 = roundv(pow10(max));
+ fracpart = roundv(pow10(max) * (ufvalue - intpart));
- if (fracpart >= pow10(max)) {
+ if (fracpart >= max10) {
intpart++;
- fracpart -= pow10(max);
+ fracpart -= max10;
}
/* convert integer part */
(caps ? "0123456789ABCDEF"
: "0123456789abcdef")[intpart % 10];
intpart = (intpart / 10);
- } while (intpart && (iplace < (int)sizeof(iplace)));
- if (iplace == sizeof iplace)
+ } while (intpart && (iplace < (int)sizeof(iconvert)));
+ if (iplace == sizeof iconvert)
iplace--;
iconvert[iplace] = 0;
: "0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
} while (fplace < max);
- if (fplace == sizeof fplace)
+ if (fplace == sizeof fconvert)
fplace--;
fconvert[fplace] = 0;