Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Currency Rounding Up

2»

Comments

  • Moderators, Technology & Internet Moderators Posts: 1,337 Mod ✭✭✭✭croo


    EyeSight wrote: »
    out of sheer curiosity, would €50.009 = €50 also?
    in money related software is it the standard to always round down no matter how high the offset is??
    Not to fork the OP's thread... but there are many rounding methods. The most common being round half up ... which most people are familiar with and would round your €50.009 to €50.01. But one method I came across is called "bankers' rounding" or "round half to even" where, as its name implies, it only rounds up (after half) to an even number. When I happened across the bankers' rounding I thought it must be an error but wikipedia has a good article on the subject that enlightened me http://en.wikipedia.org/wiki/Rounding


  • Registered Users, Registered Users 2 Posts: 3,312 ✭✭✭irishguy


    I used to work for a large bank they used either 6 or 8 digits after the decimal place. If you apply it consistently to all transactions (ensure your OS and Database support this) then you will have Zero balancing problems.


  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    I found a list of rounding algorithms here: Rounding Algorithms 101

    # Round-Ceiling (Positive Infinity)
    # Round-Away From-Zero

    These are what my case needed.

    round-summary.gif


  • Closed Accounts Posts: 2,696 ✭✭✭mark renton


    ^^

    looks to me it may have come from your text book :D


  • Closed Accounts Posts: 695 ✭✭✭yawha


    Giblet wrote: »
    That won't work, you truncate x and add .01, so you'll always have x.01 as the number if there is a remainder in the 100's or less.
    x +- .01f;
    x = ((int)x * 100) / 100.0f
    
    This will truncate after two decimal places correctly
    God dammit. Brain was not functioning. You're correct.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    john47832 wrote: »
    ^^

    looks to me it may have come from your text book :D

    129176578250159225.jpg


Advertisement