André Hentschel : oleaut32: Fix rounding.
Alexandre Julliard
julliard at winehq.org
Mon Feb 22 08:46:48 CST 2010
Module: wine
Branch: master
Commit: 77acdcc016cd8954b07bbed1dca337323d368097
URL: http://source.winehq.org/git/wine.git/?a=commit;h=77acdcc016cd8954b07bbed1dca337323d368097
Author: André Hentschel <nerv at dawncrow.de>
Date: Sun Feb 21 19:46:38 2010 +0100
oleaut32: Fix rounding.
---
dlls/oleaut32/tests/varformat.c | 10 ++++++++--
dlls/oleaut32/varformat.c | 11 ++++++++++-
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/oleaut32/tests/varformat.c b/dlls/oleaut32/tests/varformat.c
index 9d15fd9..d0975ed 100644
--- a/dlls/oleaut32/tests/varformat.c
+++ b/dlls/oleaut32/tests/varformat.c
@@ -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 */
diff --git a/dlls/oleaut32/varformat.c b/dlls/oleaut32/varformat.c
index f6c142d..370b4f0 100644
--- a/dlls/oleaut32/varformat.c
+++ b/dlls/oleaut32/varformat.c
@@ -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)
{
More information about the wine-cvs
mailing list