lib_libvsprintf: fix the float point print bug

such as code: double value = +0x1.000000000000080000000000p-600;
              printf("Hello, World!! %.7g:f64\n", value);
expected output : Hello, World!! 2.40992e-181:f64
but real output : Hello, World!! 2.40992e-B1:f64
the reason: we want printf "18", but the flag of character is 'B'
            and 'B' is '0'+18,so printf 'B';
This commit is contained in:
flyingfish89 2022-11-24 16:08:06 +08:00 committed by Alan Carvalho de Assis
parent 3caa551ff4
commit 4b87a8b079

View File

@ -878,8 +878,32 @@ flt_oper:
ndigs += 1;
}
putc(ndigs, stream);
putc('0' + exp, stream);
/* Parse the ndigs if the value of it bigger than '9' */
while (1)
{
if (ndigs >= 'd')
{
putc(((ndigs - '0') / 100) + '0', stream);
ndigs = (ndigs - '0') % 100 + '0';
}
else if (ndigs >= ':')
{
putc(((ndigs - '0') / 10) + '0', stream);
ndigs = (ndigs - '0') % 10 + '0';
}
else if(ndigs >= '0')
{
putc(ndigs, stream);
break;
}
else
{
break;
}
}
putc('0' + exp, stream);
}
goto tail;