ucrtbase: Fix away from 0 rounding in %a format.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2020-08-06 13:18:07 +02:00 committed by Alexandre Julliard
parent e475d04591
commit 04de6fe37e
2 changed files with 9 additions and 6 deletions

View file

@ -446,10 +446,10 @@ static inline int FUNC_NAME(pf_output_hex_fp)(FUNC_NAME(puts_clbk) pf_puts, void
mant >>= 4;
}
if(!flags->Precision) {
if(p[0] > '8') p[-2]++;
if(p[0] >= '8') p[-2]++;
if(!flags->Alternate) p--;
}else if(flags->Precision>0 && flags->Precision<MANT_BITS/4) {
BOOL round_up = (p[flags->Precision] > '8');
BOOL round_up = (p[flags->Precision] >= '8');
for(r=flags->Precision-1; r>=0 && round_up; r--) {
round_up = FALSE;
if(p[r]=='f' || p[r]=='F') {

View file

@ -747,18 +747,21 @@ static void test_printf_fp(void)
{ "%.a", 0.1e-20, { "0x1p-70" }},
{ "%a", 0.1e-20, { "0x1.2e3b40a0e9b4fp-70" }},
{ "%a", 4.9406564584124654e-324, { "0x0.0000000000001p-1022" }},
{ "%.0a", -1.5, { "-0x1p+0" }},
{ "%.0a", -1.5, { "-0x2p+0" }, { "-0x1p+0" }},
{ "%.0a", -0.5, { "-0x1p-1" }},
{ "%.0a", 0.5, { "0x1p-1" }},
{ "%.0a", 1.5, { "0x1p+0" }},
{ "%.0a", 1.5, { "0x2p+0" }, { "0x1p+0" }},
{ "%.0a", 1.99, { "0x2p+0" }},
{ "%.0a", 2, { "0x1p+1" }},
{ "%.0a", 9.5, { "0x1p+3" }},
{ "%.0a", 10.5, { "0x1p+3" }},
{ "%#.0a", -1.5, { "-0x1.p+0" }},
{ "%#.0a", -1.5, { "-0x2.p+0" }, { "-0x1.p+0" }},
{ "%#.0a", -0.5, { "-0x1.p-1" }},
{ "%#.0a", 0.5, { "0x1.p-1" }},
{ "%#.0a", 1.5, { "0x1.p+0" }},
{ "%#.0a", 1.5, { "0x2.p+0" }, { "0x1.p+0" }},
{ "%#.1a", 1.03125, { "0x1.1p+0" }, { "0x1.0p+0" }},
{ "%#.1a", 1.09375, { "0x1.2p+0" }, { "0x1.1p+0" }},
{ "%#.1a", 1.15625, { "0x1.3p+0" }, { "0x1.2p+0" }},
{ "%f", 0, { "0.000000" }},
{ "%e", 0, { "0.000000e+00", NULL, "0.000000e+000" }},