Ensure that underflowing negative float is represented as a positive

0, just as native oleaut32.
This commit is contained in:
Alex Villacís Lasso 2005-07-19 11:38:12 +00:00 committed by Alexandre Julliard
parent af2e7eb2cb
commit 3153aa9131
2 changed files with 14 additions and 1 deletions

View File

@ -4615,7 +4615,7 @@ static void test_VarBstrFromR4(void)
ok(hres == S_OK, "got hres 0x%08lx\n", hres);
if (bstr)
{
todo_wine ok(memcmp(bstr, szZero, sizeof(szZero)) == 0, "negative zero (got %s)\n", wtoascii(bstr));
ok(memcmp(bstr, szZero, sizeof(szZero)) == 0, "negative zero (got %s)\n", wtoascii(bstr));
}
}

View File

@ -5258,6 +5258,19 @@ static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags,
return E_INVALIDARG;
sprintfW( buff, lpszFormat, dblIn );
/* Negative zeroes are disallowed (some applications depend on this).
If buff starts with a minus, and then nothing follows but zeroes
and/or a period, it is a negative zero and is replaced with a
canonical zero. This duplicates native oleaut32 behavior.
*/
if (buff[0] == '-')
{
const WCHAR szAccept[] = {'0', '.', '\0'};
if (strlenW(buff + 1) == strspnW(buff + 1, szAccept))
{ buff[0] = '0'; buff[1] = '\0'; }
}
TRACE("created string %s\n", debugstr_w(buff));
if (dwFlags & LOCALE_USE_NLS)
{