Commit 757af5fc authored by Jon Griffiths's avatar Jon Griffiths Committed by Alexandre Julliard

Use integer math in VarCyInt, docs.

parent 950da26b
...@@ -3735,6 +3735,10 @@ HRESULT WINAPI VarCyAbs(const CY cyIn, CY* pCyOut) ...@@ -3735,6 +3735,10 @@ HRESULT WINAPI VarCyAbs(const CY cyIn, CY* pCyOut)
* RETURNS * RETURNS
* Success: S_OK. * Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination * Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*
* NOTES
* - The difference between this function and VarCyInt() is that VarCyInt() rounds
* negative numbers away from 0, while this function rounds them towards zero.
*/ */
HRESULT WINAPI VarCyFix(const CY cyIn, CY* pCyOut) HRESULT WINAPI VarCyFix(const CY cyIn, CY* pCyOut)
{ {
...@@ -3755,14 +3759,20 @@ HRESULT WINAPI VarCyFix(const CY cyIn, CY* pCyOut) ...@@ -3755,14 +3759,20 @@ HRESULT WINAPI VarCyFix(const CY cyIn, CY* pCyOut)
* RETURNS * RETURNS
* Success: S_OK. * Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination * Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*
* NOTES
* - The difference between this function and VarCyFix() is that VarCyFix() rounds
* negative numbers towards 0, while this function rounds them away from zero.
*/ */
HRESULT WINAPI VarCyInt(const CY cyIn, CY* pCyOut) HRESULT WINAPI VarCyInt(const CY cyIn, CY* pCyOut)
{ {
double d; pCyOut->int64 = cyIn.int64 / CY_MULTIPLIER;
pCyOut->int64 *= CY_MULTIPLIER;
_VarR8FromCy(cyIn, &d); if (cyIn.int64 < 0 && cyIn.int64 % CY_MULTIPLIER != 0)
d = floor(d) * CY_MULTIPLIER_F; {
OLEAUT32_DutchRound(LONGLONG, d, pCyOut->int64); pCyOut->int64 -= CY_MULTIPLIER;
}
return S_OK; return S_OK;
} }
...@@ -4557,6 +4567,10 @@ HRESULT WINAPI VarDecAbs(const DECIMAL* pDecIn, DECIMAL* pDecOut) ...@@ -4557,6 +4567,10 @@ HRESULT WINAPI VarDecAbs(const DECIMAL* pDecIn, DECIMAL* pDecOut)
* RETURNS * RETURNS
* Success: S_OK. * Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination * Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*
* NOTES
* - The difference between this function and VarDecInt() is that VarDecInt() rounds
* negative numbers away from 0, while this function rounds them towards zero.
*/ */
HRESULT WINAPI VarDecFix(const DECIMAL* pDecIn, DECIMAL* pDecOut) HRESULT WINAPI VarDecFix(const DECIMAL* pDecIn, DECIMAL* pDecOut)
{ {
...@@ -4585,17 +4599,18 @@ HRESULT WINAPI VarDecFix(const DECIMAL* pDecIn, DECIMAL* pDecOut) ...@@ -4585,17 +4599,18 @@ HRESULT WINAPI VarDecFix(const DECIMAL* pDecIn, DECIMAL* pDecOut)
* RETURNS * RETURNS
* Success: S_OK. * Success: S_OK.
* Failure: DISP_E_OVERFLOW, if the value will not fit in the destination * Failure: DISP_E_OVERFLOW, if the value will not fit in the destination
*
* NOTES
* - The difference between this function and VarDecFix() is that VarDecFix() rounds
* negative numbers towards 0, while this function rounds them away from zero.
*/ */
HRESULT WINAPI VarDecInt(const DECIMAL* pDecIn, DECIMAL* pDecOut) HRESULT WINAPI VarDecInt(const DECIMAL* pDecIn, DECIMAL* pDecOut)
{ {
if (DEC_SIGN(pDecOut) & ~DECIMAL_NEG) if (DEC_SIGN(pDecOut) & ~DECIMAL_NEG)
return E_INVALIDARG; return E_INVALIDARG;
if (!DEC_SCALE(pDecIn)) if (!(DEC_SIGN(pDecOut) & DECIMAL_NEG) || !DEC_SCALE(pDecIn))
{ return VarDecFix(pDecIn, pDecOut); /* The same, if +ve or no fractionals */
*pDecOut = *pDecIn; /* Already an integer */
return S_OK;
}
FIXME("semi-stub!\n"); FIXME("semi-stub!\n");
return DISP_E_OVERFLOW; return DISP_E_OVERFLOW;
......
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