BankRound Function
Returns the number rounded to the number of decimal places using the rules of bankers rounding.
Syntax
BankRound(number, digits)
Returns the number rounded to the number of decimal places using the rules of bankers rounding.
Arguments
number
Numeric - The number to round.
digits
Integer - The number of decimal digits to round the number to.
Remarks
- With bankers rounding, note that .5 (.05, .005, etc) can round up sometimes and down sometimes. When the number to round is exactly halfway between two rounded values, the result is the rounded value that has an even digit in the far right decimal position. So both 1.5 and 2.5 round to 2, and 3.5 and 4.5 both round to 4. This process is also known as rounding toward even, or Gaussian rounding.
Example:
BankRound(2.55, 1); // returns 2.6
Example:
BankRound(2.45, 1); // returns 2.4