Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Banker's rounding formula in Excel

Tags:

.net

excel

It is a well known problem that by default, .NET uses Banker's rounding whereby X.5 is rounded to nearest even number. Excel, on the other hand uses arithmetic rounding where X.5 is always rounded up, just like most of us have been taught at school.

Is it possible to perform banker's rounding in Excel using a formula?

like image 363
Ruslan Avatar asked Jun 01 '17 14:06

Ruslan


People also ask

Can Excel do bankers rounding?

What is round to even in Excel? Round to even also called bankers rounding, basically it is just like normal rounding, except when the number to be rounded on is number 5. If the digit before the 5 is odd, you should round up, and if the digit before the 5 is even, you should round down.

How do you do bankers rounding?

It's a commonly used method for rounding taxes. Rather than rounding 0.5 and higher up, and 0.4 and lower down, bankers rounding rounds 0.5 to the nearest even number. Essentially if the cent value of the tax total is odd, the 0.5 (half-cent) rounds upwards; If the cent value is even, the half-cent rounds it downwards.

How do you automatically round numbers in Excel?

For example, to round 2345678 down to 3 significant digits, you use the ROUNDDOWN function with the parameter -4, as follows: = ROUNDDOWN(2345678,-4). This rounds the number down to 2340000, with the "234" portion as the significant digits.


2 Answers

Use this formula:

=IF(AND(ISEVEN(A1*10^0),MOD(A1*10^0,1)<=0.5),ROUNDDOWN(A1,0),ROUND(A1,0))

Replace all the 0, there are 4 of them, with the significance of the desired rounding.

Or you can create a user defined function to use VBA Round, which is Banker's Rounding:

Function BankerRound(rng As Double, sig As Integer) As Double

    BankerRound = Round(rng, sig)
End Function

Then it would simply be:

=BankerRound(A1,0)
like image 62
Scott Craner Avatar answered Sep 20 '22 07:09

Scott Craner


=IF(AND(ISEVEN(A1*10^0),MOD(A1*10^0,1)<=0.5),ROUNDDOWN(A1,0),ROUND(A1,0))

I used this formula and it worked great, but in some cases, it was not working because the 0.5 actually was 0.5000000000000000004550000000000000000.

The fix is to ROUND the MOD statement to two(2) decimal places so that the computation reads:

=IF(AND(ISEVEN(A1*10^0),ROUND(MOD(A1*10^0,1),2)<=0.5),ROUNDDOWN(A1,0),ROUND(A1,0))
like image 40
user10548053 Avatar answered Sep 24 '22 07:09

user10548053