This method performs rounding to a specified number of decimal points (i.e., the precision parameter).
Rounding is done so that an even value is selected if the two possible values are equally close. This type of rounding is also known as: unbiased rounding, convergent rounding, statistician's rounding, or Gaussian rounding. The following are examples of this method in use:
* roundHalfToEven( 1.1742, 2 ) results in 1.17
*
- Parameters
-
withDecimal | [ in ] A numeric value with a value after the decimal point (e.g., 4.6) |
precision | [ in ] Indicates the number of decimal digits required after the decimal point. The "withDecimal" parameter is rounded to a multiple of 10 to the power -precision. For example, if this parameter is 2 then withDecimal is rounded to a multiple of 0.01. If precision is 0 then withDecimal is rounded to a multiple of 1, thus to an integer. Lastly, if precision is negative, for example -2, then withDecimal is rounded to a multiple of 100. Negative precision will also set all decimal digits to zero. |
pRound | [ out ] see examples above |
- Returns
Success | P6R::eOk | |
Failure | P6R::eInvalidArg | One of the parameters is NULL or inSize is zero. |
P6R::eNotInitialized | A successful call to initialize has not been done. |