Piotr Caban : msvcrt: Improved _wcstod_l precision.
Alexandre Julliard
julliard at winehq.org
Tue Nov 6 14:27:29 CST 2012
Module: wine
Branch: master
Commit: 505e5a162fb94e5a3789191121e5b5fd32687d11
URL: http://source.winehq.org/git/wine.git/?a=commit;h=505e5a162fb94e5a3789191121e5b5fd32687d11
Author: Piotr Caban <piotr at codeweavers.com>
Date: Tue Nov 6 10:33:40 2012 +0100
msvcrt: Improved _wcstod_l precision.
---
dlls/msvcrt/wcs.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index 32ee76b..08628d4 100644
--- a/dlls/msvcrt/wcs.c
+++ b/dlls/msvcrt/wcs.c
@@ -202,7 +202,8 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
int exp=0, sign=1;
const MSVCRT_wchar_t *p;
double ret;
- BOOL found_digit = FALSE;
+ long double lret=1, expcnt = 10;
+ BOOL found_digit = FALSE, negexp;
if (!MSVCRT_CHECK_PMT(str != NULL)) return 0;
@@ -287,10 +288,16 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
_control87(MSVCRT__EM_DENORMAL|MSVCRT__EM_INVALID|MSVCRT__EM_ZERODIVIDE
|MSVCRT__EM_OVERFLOW|MSVCRT__EM_UNDERFLOW|MSVCRT__EM_INEXACT, 0xffffffff);
- if(exp>0)
- ret = (double)sign*d*pow(10, exp);
- else
- ret = (double)sign*d/pow(10, -exp);
+ negexp = (exp < 0);
+ if(negexp)
+ exp = -exp;
+ while(exp) {
+ if(exp & 1)
+ lret *= expcnt;
+ exp /= 2;
+ expcnt = expcnt*expcnt;
+ }
+ ret = (long double)sign * (negexp ? d/lret : d*lret);
_control87(fpcontrol, 0xffffffff);
More information about the wine-cvs
mailing list