Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    Des Moines, Iowa
    Posts
    219
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Have I Finally Become Dense? (Rounding Issue)

    I've been at PHP for more years than I care to say... And now I think I've become dense or maybe I should quit my job and become a sanitation driver. :-)

    Client has a total * tax rate = something like .6201... Their POS system (not PHP) rounds .6201 up to .63 - which makes zero sense to me...

    How in the world would I force my round function to insist that 0 in the thousands place is high enough to round up to 3. This defies mathematics and I'm stumped.

    Thanks!
    Rich S. Wyatt
    D3 Web Creations

  • #2
    New Coder
    Join Date
    Dec 2012
    Location
    USA
    Posts
    82
    Thanks
    3
    Thanked 17 Times in 17 Posts
    You say this is a PoS (I'm assuming you mean Point of Sale and not Piece of S**t).

    A previous job of mine was a manager at a new start-up resturant. I worked closely with the PoS guys, so if something went wrong I could fix it on the spot.

    Through this, I became very familiar with PoS's.

    If there is any thousandth's decimal, most, if not all, PoS's will always round up - why? Money. Those fractions of a penny add up after a full day of sales. So if it didn't round up, the business could potential take a big hit, think 200 orders a day, each with .004 cents cut from that is .80 cents. .80 cents a day is $292 dollars a year - and that's thinking very conservatively.

    For example, have you ever seen Office Space? It is the same principal.

    ===

    Now as for your question, I'm not completely sure what you are asking...
    Last edited by TFlan; 01-10-2013 at 12:05 AM.

  • #3
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,444
    Thanks
    11
    Thanked 310 Times in 309 Posts
    You would add 0.005 before rounding. .6201+.005 = .6351, which rounds up to .63

    Dave

  • #4
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    ceil()

    always round up!
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com


  •  

    Posting Permissions

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