oleaut32: Use scientific notation if it prevents a loss of accuracy.
This commit is contained in:
parent
1b32ac45f8
commit
8a8d1dedcf
2 changed files with 27 additions and 9 deletions
|
@ -4679,12 +4679,22 @@ static void test_VarBstrFromR8(void)
|
|||
{
|
||||
static const struct r8_test tests_en[] =
|
||||
{
|
||||
{ 0.5, L"0.5" },
|
||||
{ 0.05, L"0.05" },
|
||||
{ 0.005, L"0.005" },
|
||||
{ 0.0005, L"0.0005" },
|
||||
{ 0.00005, L"0.00005" },
|
||||
{ 0.000005, L"0.000005" },
|
||||
{ 0.56789, L"0.56789" },
|
||||
{ 5.6789e-2, L"0.056789" },
|
||||
{ 5.6789e-3, L"0.0056789" },
|
||||
{ 5.6789e-4, L"0.00056789" },
|
||||
{ 5.6789e-5, L"0.000056789" },
|
||||
{ 5.6789e-6, L"0.0000056789" },
|
||||
{ 5.6789e-7, L"0.00000056789" },
|
||||
{ 5.6789e-8, L"0.000000056789" },
|
||||
{ 5.6789e-9, L"0.0000000056789" },
|
||||
{ 5.6789e-10, L"0.00000000056789" },
|
||||
{ 5.6789e-11, L"0.000000000056789" },
|
||||
{ 5.6789e-12, L"5.6789E-12" },
|
||||
{ 5.6789e-13, L"5.6789E-13" },
|
||||
{ 5.6789e-14, L"5.6789E-14" },
|
||||
{ 5.6789e-15, L"5.6789E-15" },
|
||||
{ 5.6789e-16, L"5.6789E-16" },
|
||||
|
||||
{ 1.0e8, L"100000000" },
|
||||
{ 1.0e12, L"1000000000000" },
|
||||
|
|
|
@ -6550,10 +6550,18 @@ static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags,
|
|||
if (!(locale = _create_locale(LC_ALL, "C"))) return E_OUTOFMEMORY;
|
||||
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)
|
||||
if (e)
|
||||
{
|
||||
len = _swprintf_l(buff, ARRAY_SIZE(buff), L"%.*f", locale, ndigits, dblIn);
|
||||
while (len > 0 && (buff[len-1] == '0')) len--;
|
||||
int extra_decimals;
|
||||
WCHAR *dot;
|
||||
|
||||
dot = wcschr(buff, '.');
|
||||
extra_decimals = dot ? e - dot - 2 : 0;
|
||||
if (labs(wcstol(e+1, NULL, 10)) + extra_decimals < 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);
|
||||
|
|
Loading…
Add table
Reference in a new issue