Commit 4d1ad4f9 authored by Daniel Lehman's avatar Daniel Lehman Committed by Alexandre Julliard

oleaut32: Use scientific notation only for larger numbers in VarBstrFromR[48].

parent 55e4aa7a
......@@ -4525,7 +4525,6 @@ struct r4_test
{
float val;
const wchar_t *expect;
BOOL todo;
};
static void test_VarBstrFromR4(void)
......@@ -4536,8 +4535,8 @@ static void test_VarBstrFromR4(void)
{ 0.05, L"0.05" },
{ 0.005, L"0.005" },
{ 0.0005, L"0.0005" },
{ 0.00005, L"0.00005", TRUE },
{ 0.000005, L"0.000005", TRUE },
{ 0.00005, L"0.00005" },
{ 0.000005, L"0.000005" },
{ 1.0e8, L"1E+08" },
{ 1.0e12, L"1E+12" },
......@@ -4564,8 +4563,8 @@ static void test_VarBstrFromR4(void)
{ 0.05, L"0,05" },
{ 0.005, L"0,005" },
{ 0.0005, L"0,0005" },
{ 0.00005, L"0,00005", TRUE },
{ 0.000005, L"0,000005", TRUE },
{ 0.00005, L"0,00005" },
{ 0.000005, L"0,000005" },
{ 1.0e8, L"1E+08" },
{ 1.0e12, L"1E+12" },
......@@ -4648,7 +4647,6 @@ static void test_VarBstrFromR4(void)
ok(hres == S_OK, "got hres 0x%08lx\n", hres);
if (bstr)
{
todo_wine_if(cur->todo)
ok(wcscmp(bstr, cur->expect) == 0, "expected '%ls', got '%ls'\n", cur->expect, bstr);
SysFreeString(bstr);
}
......@@ -4664,7 +4662,6 @@ static void test_VarBstrFromR4(void)
ok(hres == S_OK, "got hres 0x%08lx\n", hres);
if (bstr)
{
todo_wine_if(cur->todo)
ok(wcscmp(bstr, cur->expect) == 0, "expected '%ls', got '%ls'\n", cur->expect, bstr);
SysFreeString(bstr);
}
......@@ -4676,7 +4673,6 @@ struct r8_test
{
double val;
const wchar_t *expect;
BOOL todo;
};
static void test_VarBstrFromR8(void)
......@@ -4687,8 +4683,8 @@ static void test_VarBstrFromR8(void)
{ 0.05, L"0.05" },
{ 0.005, L"0.005" },
{ 0.0005, L"0.0005" },
{ 0.00005, L"0.00005", TRUE },
{ 0.000005, L"0.000005", TRUE },
{ 0.00005, L"0.00005" },
{ 0.000005, L"0.000005" },
{ 1.0e8, L"100000000" },
{ 1.0e12, L"1000000000000" },
......@@ -4715,8 +4711,8 @@ static void test_VarBstrFromR8(void)
{ 0.05, L"0,05" },
{ 0.005, L"0,005" },
{ 0.0005, L"0,0005" },
{ 0.00005, L"0,00005", TRUE },
{ 0.000005, L"0,000005", TRUE },
{ 0.00005, L"0,00005" },
{ 0.000005, L"0,000005" },
{ 1.0e8, L"100000000" },
{ 1.0e12, L"1000000000000" },
......@@ -4751,7 +4747,6 @@ static void test_VarBstrFromR8(void)
ok(hres == S_OK, "got hres 0x%08lx\n", hres);
if (bstr)
{
todo_wine_if(cur->todo)
ok(wcscmp(bstr, cur->expect) == 0, "expected '%ls', got '%ls'\n", cur->expect, bstr);
SysFreeString(bstr);
}
......@@ -4767,7 +4762,6 @@ static void test_VarBstrFromR8(void)
ok(hres == S_OK, "got hres 0x%08lx\n", hres);
if (bstr)
{
todo_wine_if(cur->todo)
ok(wcscmp(bstr, cur->expect) == 0, "expected '%ls', got '%ls'\n", cur->expect, bstr);
SysFreeString(bstr);
}
......
......@@ -6538,16 +6538,24 @@ static BSTR VARIANT_BstrReplaceDecimal(const WCHAR * buff, LCID lcid, ULONG dwFl
}
static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags,
BSTR* pbstrOut, LPCWSTR lpszFormat)
BSTR* pbstrOut, int ndigits)
{
_locale_t locale;
WCHAR buff[256];
WCHAR *e, buff[256];
int len;
if (!pbstrOut)
return E_INVALIDARG;
if (!(locale = _create_locale(LC_ALL, "C"))) return E_OUTOFMEMORY;
_swprintf_l(buff, ARRAY_SIZE(buff), lpszFormat, locale, dblIn);
len = _swprintf_l(buff, ARRAY_SIZE(buff), L"%.*G", locale, ndigits, dblIn);
e = wcschr(buff, 'E');
if (e && labs(wcstol(e+1, NULL, 10)) < ndigits)
{
len = _swprintf_l(buff, ARRAY_SIZE(buff), L"%.*f", locale, ndigits, dblIn);
while (len > 0 && (buff[len-1] == '0')) len--;
}
buff[len] = 0;
_free_locale(locale);
/* Negative zeroes are disallowed (some applications depend on this).
......@@ -6598,7 +6606,7 @@ static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags,
*/
HRESULT WINAPI VarBstrFromR4(FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
{
return VARIANT_BstrFromReal(fltIn, lcid, dwFlags, pbstrOut, L"%.7G");
return VARIANT_BstrFromReal(fltIn, lcid, dwFlags, pbstrOut, 7);
}
/******************************************************************************
......@@ -6619,7 +6627,7 @@ HRESULT WINAPI VarBstrFromR4(FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR* pbstrO
*/
HRESULT WINAPI VarBstrFromR8(double dblIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut)
{
return VARIANT_BstrFromReal(dblIn, lcid, dwFlags, pbstrOut, L"%.15G");
return VARIANT_BstrFromReal(dblIn, lcid, dwFlags, pbstrOut, 15);
}
/******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment