+ Reply to Thread
Results 1 to 10 of 10

Banker's Round/Half to Even Rounding Double Rounding

  1. #1
    Registered User
    Join Date
    04-09-2019
    Location
    Columbus, OH
    MS-Off Ver
    2010
    Posts
    5

    Banker's Round/Half to Even Rounding Double Rounding

    I'm trying to set up Banker's rounding/Half to even. I found this formula from Barry Houdini

    =ROUND(A2,0)-(MOD(ROUND(A2*10,0),20)=5)

    Which works great, until there's a number with 4.45-4.49 in it.

    34.44 rounds, correctly, to 34
    34.45 rounds, incorrectly, to 33

    Evaluating the formula shows that it's double rounding. A few steps in, I encounter the difference.

    round(344.4,0) = 344
    round(344.5,0) = 345

    And this causes the MOD( result to change from 5 to 4. Which means it incorrectly subtracts 1 at the end.

    Any suggestions on how to get passed that quirk? Thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Banker's Round/Half to Even Rounding Double Rounding

    How about

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: Banker's Round/Half to Even Rounding Double Rounding

    Would you consider a VBA UDF? VBA's Round() function (unlike Excel's ROUND() function) uses banker's rounding natively. A simple VBA UDF like
    Please Login or Register  to view this content.
    should perform this banker's rounding task.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Registered User
    Join Date
    04-09-2019
    Location
    Columbus, OH
    MS-Off Ver
    2010
    Posts
    5

    Re: Banker's Round/Half to Even Rounding Double Rounding

    Richard,
    Thanks for the idea. That one seems to have it's own issues. It rounded 12.8 to 12 and not to 13.

    Mr Shorty,
    I've dabbled in some VBA, and tried yours out, but it seems to have an issue too. It rounded 12.51 to 13 and not 12. My formula is

    =BankRound(A1,0)

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Banker's Round/Half to Even Rounding Double Rounding

    Maybe try
    =ROUND(A2,0)-(MOD(A2,1)=0.5)*MOD(ROUND(A2,0),2)

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: Banker's Round/Half to Even Rounding Double Rounding

    Do we have a different definition of banker's rounding at play? My understanding is that these "tie-breaker" rules apply to cases where the fraction is exactly halfway between (exactly 0.5). To my understanding, 12.51 is clearly closer to 13 than to 12 (differences of 0.49 vs. 0.51), so should naturally round to 13. Are you looking for something like Bo_Ry is suggesting, where you first round to the nearest tenth before rounding to the nearest integer? That kind of algorithm is going to round 12.54999999 down to 12 and round 11.45000001 up to 12. Is that the rounding algorithm you are wanting?

  7. #7
    Registered User
    Join Date
    04-09-2019
    Location
    Columbus, OH
    MS-Off Ver
    2010
    Posts
    5

    Re: Banker's Round/Half to Even Rounding Double Rounding

    MrShorty,
    Banker's rounding is also called "half to even" we use for our chemistry is the same as the definition from wiki.
    "A tie-breaking rule without positive/negative bias and without bias toward/away from zero is round half to even. By this convention, if the fractional part of x is 0.5, then y is the even integer nearest to x. Thus, for example, +23.5 becomes +24, as does +24.5; while −23.5 becomes −24, as does −24.5. This function minimizes the expected error when summing over rounded figures, even when the inputs are mostly positive or mostly negative."


    12.4# rounds normally to 12
    12.5# always rounds to 12, regardless of what numbers are after. It's only the number following the decimal that counts.
    12.6# rounds normally to 13

    So, Bo_Ry's also doesn't work either.

  8. #8
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Banker's Round/Half to Even Rounding Double Rounding

    How about
    =ROUND(A2,0)-SIGN(A2)*(TRUNC(MOD(A2,1)*10,)=5)*MOD(ROUND(A2,0),2)

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: Banker's Round/Half to Even Rounding Double Rounding

    So, anything from 11.5 to 12.599999... should round to 12. 12.6 to 13.49999999 should round to 13. 13.5 to 14.59999999 should round to 14? This does not feel like banker's rounding to me. It feels like banker's rounding after rounding down to the nearest tenth. If the goal is to minimize bias, then it feels like this algorithm is going to round up 10% more often than it rounds down (or is it the other way around, it will round down more often than it rounds up?).

    How about =BankRound(ROUNDDOWN(value,1),0) (using the same UDF I proposed in post #3)? That should give the behavior you describe.
    Last edited by MrShorty; 07-22-2019 at 01:56 PM.

  10. #10
    Registered User
    Join Date
    04-09-2019
    Location
    Columbus, OH
    MS-Off Ver
    2010
    Posts
    5

    Re: Banker's Round/Half to Even Rounding Double Rounding

    Bo_Ry,
    That's perfect! It does just what I need. Now to see if I can decipher what you did so I can add it to my repertoire.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I want my worksheet to use Banker's Rounding
    By jplink49 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-05-2021, 03:21 AM
  2. Banker's Rounding Pitfall
    By Gregor y in forum Access Tables & Databases
    Replies: 0
    Last Post: 08-03-2015, 04:17 PM
  3. Replies: 2
    Last Post: 01-22-2013, 02:05 PM
  4. Rounding to nearest half hour
    By kjambug in forum Excel General
    Replies: 3
    Last Post: 11-11-2010, 03:06 PM
  5. Rounding up to nearest half
    By marknorton in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-25-2008, 11:56 AM
  6. rounding to the nearest half ( .5)
    By Leaper@FakeEail.cooo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2005, 06:05 PM
  7. [SOLVED] Banker's Rounding - need help!
    By Somecallmejosh in forum Excel General
    Replies: 3
    Last Post: 01-20-2005, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1