From d3cc9d1ca69c2233dde113f379e2bf8e0a9fab82 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Mon, 11 Jul 2016 09:46:16 +0200 Subject: [PATCH] webservices: Use a long double variable in format_double. Signed-off-by: Hans Leidekker Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- configure | 1 + configure.ac | 1 + dlls/webservices/writer.c | 21 ++++++++++++++------- include/config.h.in | 3 +++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 01321fa8ad1..0b1528de82a 100755 --- a/configure +++ b/configure @@ -16939,6 +16939,7 @@ for ac_func in \ lrintf \ lround \ lroundf \ + powl \ remainder \ remainderf \ rint \ diff --git a/configure.ac b/configure.ac index e7c1dd19317..595b8f19398 100644 --- a/configure.ac +++ b/configure.ac @@ -2535,6 +2535,7 @@ AC_CHECK_FUNCS(\ lrintf \ lround \ lroundf \ + powl \ remainder \ remainderf \ rint \ diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c index b1afcb81fc5..452ee46d673 100644 --- a/dlls/webservices/writer.c +++ b/dlls/webservices/writer.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" #include #include #include @@ -1049,9 +1050,10 @@ static ULONG format_uint64( const UINT64 *ptr, unsigned char *buf ) static ULONG format_double( const double *ptr, unsigned char *buf ) { - static const double precision = 0.0000000000000001; +#ifdef HAVE_POWL + static const long double precision = 0.0000000000000001; unsigned char *p = buf; - double val = *ptr; /* FIXME: use long double */ + long double val = *ptr; int neg, mag, mag2, use_exp; if (isnan( val )) @@ -1081,12 +1083,12 @@ static ULONG format_double( const double *ptr, unsigned char *buf ) val = -val; } - mag = log10( val ); + mag = log10l( val ); use_exp = (mag >= 15 || (neg && mag >= 1) || mag <= -1); if (use_exp) { if (mag < 0) mag -= 1; - val = val / pow( 10.0, mag ); + val = val / powl( 10.0, mag ); mag2 = mag; mag = 0; } @@ -1094,14 +1096,14 @@ static ULONG format_double( const double *ptr, unsigned char *buf ) while (val > precision || mag >= 0) { - double weight = pow( 10.0, mag ); + long double weight = powl( 10.0, mag ); if (weight > 0 && !isinf( weight )) { - int digit = floor( val / weight ); + int digit = floorl( val / weight ); val -= digit * weight; *(p++) = '0' + digit; } - if (!mag && val > 0) *(p++) = '.'; + if (!mag && val > precision) *(p++) = '.'; mag--; } @@ -1131,6 +1133,10 @@ static ULONG format_double( const double *ptr, unsigned char *buf ) } return p - buf; +#else + FIXME( "powl not found at build time\n" ); + return 0; +#endif } static ULONG format_guid( const GUID *ptr, unsigned char *buf ) @@ -1212,6 +1218,7 @@ static HRESULT text_to_utf8text( const WS_XML_TEXT *text, WS_XML_UTF8_TEXT **ret if (!set_fp_rounding( &fpword )) return E_NOTIMPL; len = format_double( &double_text->value, buf ); restore_fp_rounding( fpword ); + if (!len) return E_NOTIMPL; if (!(*ret = alloc_utf8_text( buf, len ))) return E_OUTOFMEMORY; return S_OK; } diff --git a/include/config.h.in b/include/config.h.in index 6fd84bf4309..a4a4bb42d8c 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -672,6 +672,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_PORT_H +/* Define to 1 if you have the `powl' function. */ +#undef HAVE_POWL + /* Define if we can use ppdev.h for parallel port access */ #undef HAVE_PPDEV -- 2.11.4.GIT