oleaut32: Fix rounding.

This commit is contained in:
André Hentschel 2010-02-21 19:46:38 +01:00 committed by Alexandre Julliard
parent bc07b48b38
commit 77acdcc016
2 changed files with 18 additions and 3 deletions

View File

@ -381,8 +381,14 @@ static void test_VarFormat(void)
VARFMT(VT_R8,V_R8,-0.1,".#",S_OK,"-.1");
VARFMT(VT_R8,V_R8,0.099,"#.#",S_OK,".1");
VARFMT(VT_R8,V_R8,0.0999,"#.##",S_OK,".1");
/* for large negative exponents, wine truncates instead of rounding */
todo_wine VARFMT(VT_R8,V_R8,0.099,"#.##",S_OK,".1");
VARFMT(VT_R8,V_R8,0.099,"#.##",S_OK,".1");
VARFMT(VT_R8,V_R8,0.0099,"#.##",S_OK,".01");
VARFMT(VT_R8,V_R8,0.0049,"#.##",S_OK,".");
VARFMT(VT_R8,V_R8,0.0094,"#.##",S_OK,".01");
VARFMT(VT_R8,V_R8,0.00099,"#.##",S_OK,".");
VARFMT(VT_R8,V_R8,0.0995,"#.##",S_OK,".1");
VARFMT(VT_R8,V_R8,8.0995,"#.##",S_OK,"8.1");
VARFMT(VT_R8,V_R8,0.0994,"#.##",S_OK,".1");
/* 'out' is not cleared */

View File

@ -1285,12 +1285,21 @@ static HRESULT VARIANT_FormatNumber(LPVARIANT pVarIn, LPOLESTR lpszFormat,
have_frac = -pad;
pad = 0;
}
if(exponent < 0 && exponent > (-256 + have_int + have_frac))
{
/* Remove exponent notation */
memmove(rgbDig - exponent, rgbDig, have_int + have_frac);
ZeroMemory(rgbDig, -exponent);
have_frac -= exponent;
exponent = 0;
}
}
/* Rounding the number */
if (have_frac > need_frac)
{
prgbDig = &rgbDig[have_int + need_frac];
prgbDig = &rgbDig[have_int + need_frac ? need_frac + 1 : 0];
if (*prgbDig < 5) prgbDig--;
have_frac = need_frac;
if (*prgbDig >= 5)
{