When we go further from what you already discovered yourself, we end up in the implementation of the VarDecRound function. This function has exactly one branch where it returns an error code, and that is when its second argument cDecimals
is smaller than zero. This argument indicates the number of decimal digits to round to:
if (cDecimals < 0)
return E_INVALIDARG;
(this kind of assertion is the equivalent of what an ArgumentException
would be in .NET)
As James Thorpe pointed out in a comment on OP, a similar assertion is done further up the call chain, here:
if (decimals < 0 || decimals > 28)
FCThrowArgumentOutOfRangeVoid(...)
Conclusion:
Execution cannot reach the point that would result in throwing the OverflowException
as documented:
- OverflowException seems to have been used internally as a catch-all mechanism, much like OutOfMemoryException in GDI+
- The documentation does not match the actual implementation
- OverflowException does not even make sense conceptually. Rounding a value up or down in the same data type cannot possibly exceed an integral min or max range, because the candidate value must itself be in range (rounding method used)
OverflowException
on line 188. – PatnodeVarDecRound
. At first glance, I can't see why it would return a failure result toFCallRound
(resulting in the exception being thrown). It either returnsE_INVALIDARG
, but the condition for that has already been checked byFCallRound
, orNOERROR
, so it seems that theOverflowException
shouldn't actually ever be thrown. – Patnode