VarNumFromParseNum Function
Once the number is parsed, the caller can call VarNumFromParseNum to convert the parse results to a number. The NUMPARSE structure and digit array can be passed in unchanged from the VarParseNumFromStr call or you can fill in the parameters from any source. This function will choose the smallest type allowed that can hold the result value with as little precision loss as possible. The result variant is an [out] parameter, so its contents are not freed before storing the result.
HRESULT VarNumFromParseNum( NUMPARSE* pnumprs, unsigned char* rgbDig, unsigned long dwVtBits, VARIANT* pvar );
The return value obtained from the returned HRESULT is one of the following.
Value | Meaning |
|---|---|
S_OK | Success. |
E_OUTOFMEMORY | Out of memory. |
DISP_E_OVERFLOW | The number is too large to be represented in an allowed type. There is no error if precision is lost in the conversion. |
For rounding decimal numbers, the digit array must be at least one digit longer than the maximum required for data types. The maximum number of digits required for the DECIMAL data type is 29, so the digit array must have room for 30 digits. There must also be enough digits to accept the number in octal, if that parsing options is selected. (Hexadecimal and octal numbers are limited by VarNumFromParseNum to the magnitude of an unsigned long [32 bits], so they need 11 octal digits.)