VarParseNumFromStr: Keep zeros after decimal point, correctly keep
track of trailing zeros in a decimal number. VarNumFromParseNum: Don't error on decimal expressions for zero.
This commit is contained in:
parent
8d3111ca26
commit
f61786d444
|
@ -1050,10 +1050,20 @@ static void test_VarParseNumFromStr(void)
|
|||
EXPECT2(5,1);
|
||||
|
||||
/* Keep trailing zeros on whole number part of a decimal */
|
||||
CONVERT("40.1", NUMPRS_STD);
|
||||
CONVERT("10.1", NUMPRS_STD);
|
||||
EXPECT(3,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
|
||||
EXPECT2(4,0);
|
||||
EXPECT2(1,0);
|
||||
EXPECTRGB(2,1);
|
||||
|
||||
/* Zeros after decimal sign */
|
||||
CONVERT("0.01", NUMPRS_STD);
|
||||
EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-2);
|
||||
EXPECT2(1,FAILDIG);
|
||||
|
||||
/* Trailing zeros after decimal part */
|
||||
CONVERT("0.10", NUMPRS_STD);
|
||||
EXPECT(1,NUMPRS_STD,NUMPRS_DECIMAL,4,0,-1);
|
||||
EXPECT2(1,0);
|
||||
}
|
||||
|
||||
static HRESULT (WINAPI *pVarNumFromParseNum)(NUMPARSE*,BYTE*,ULONG,VARIANT*);
|
||||
|
@ -1161,6 +1171,11 @@ static void test_VarNumFromParseNum(void)
|
|||
/* -0.5 */
|
||||
SETRGB(0, 5); CONVERT(1,0,NUMPRS_NEG,1,0,~0u, VTBIT_UI1); EXPECT_UI1(0);
|
||||
|
||||
/* Floating point zero is OK */
|
||||
/* 0.00000000E0 */
|
||||
SETRGB(0, 0); CONVERT(1,0,NUMPRS_DECIMAL|NUMPRS_EXPONENT,12,0,-8, VTBIT_R8);
|
||||
EXPECT_R8(0.0);
|
||||
|
||||
/* Float is acceptable for an integer input value */
|
||||
SETRGB(0, 1); CONVERT(1,0,0,1,0,0, VTBIT_R4); EXPECT_R4(1.0f);
|
||||
/* As is double */
|
||||
|
|
|
@ -1743,6 +1743,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
|
|||
dwState |= B_LEADING_ZERO;
|
||||
cchUsed++;
|
||||
lpszStr++;
|
||||
pNumprs->nPwr10--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1823,11 +1824,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
|
|||
} else {
|
||||
while (pNumprs->cDig > 1 && !rgbTmp[pNumprs->cDig - 1])
|
||||
{
|
||||
if (pNumprs->dwOutFlags & NUMPRS_DECIMAL)
|
||||
pNumprs->nPwr10--;
|
||||
else
|
||||
pNumprs->nPwr10++;
|
||||
|
||||
pNumprs->cDig--;
|
||||
}
|
||||
}
|
||||
|
@ -1837,11 +1834,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
|
|||
/* Remove trailing zeros from the last (whole number or decimal) part */
|
||||
while (pNumprs->cDig > 1 && !rgbTmp[pNumprs->cDig - 1])
|
||||
{
|
||||
if (pNumprs->dwOutFlags & NUMPRS_DECIMAL)
|
||||
pNumprs->nPwr10--;
|
||||
else
|
||||
pNumprs->nPwr10++;
|
||||
|
||||
pNumprs->cDig--;
|
||||
}
|
||||
}
|
||||
|
@ -2339,7 +2332,7 @@ HRESULT WINAPI VarNumFromParseNum(NUMPARSE *pNumprs, BYTE *rgbDig,
|
|||
|
||||
while (divisor10 > 10)
|
||||
{
|
||||
if (whole < dblMinimums[10])
|
||||
if (whole < dblMinimums[10] && whole != 0)
|
||||
{
|
||||
dwVtBits &= ~(VTBIT_R4|VTBIT_R8|VTBIT_CY); /* Underflow */
|
||||
bOverflow = TRUE;
|
||||
|
@ -2350,7 +2343,7 @@ HRESULT WINAPI VarNumFromParseNum(NUMPARSE *pNumprs, BYTE *rgbDig,
|
|||
}
|
||||
if (divisor10)
|
||||
{
|
||||
if (whole < dblMinimums[divisor10])
|
||||
if (whole < dblMinimums[divisor10] && whole != 0)
|
||||
{
|
||||
dwVtBits &= ~(VTBIT_R4|VTBIT_R8|VTBIT_CY); /* Underflow */
|
||||
bOverflow = TRUE;
|
||||
|
|
Loading…
Reference in New Issue