/* Unsigned long long only allows for 20 digits of precision
* which is already more than double supports, so we limit the
* digits to this. long double might require an increase if it is ever
* implemented.
*/
if (ndigit > 20)
ndigit = 20;
if (f < 0.0) {
sign = 1;
f = -f;
buf++;
}
scal = 1;
for (i=ndigit; i>0; i--)
scal *= 10;
k = f + 0.1 / scal;
f2 = f - k;
if (!f) {
PSH('0');
if(ndigit > 0)
PSH('.');
for (i=0;i<ndigit;i++)
PSH('0');
PSH(0);
return c;
}
i = 1;
while (f >= 10.0) {
f /= 10.0;
i++;
}
buf += i + ndigit + 1;
PSH1(0);
if(ndigit > 0) {
t = f2 * scal;
z = t + 0.5;
for (i = 0;i < ndigit;i++)
{
PSH1('0'+ (z % 10));
z /= 10;
}
PSH1('.');
}
else
PSH1(0);