Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-09-2013, 10:39 PM   PM User | #1
rswyatt
Regular Coder

 
Join Date: Jan 2004
Location: Des Moines, Iowa
Posts: 219
Thanks: 0
Thanked 0 Times in 0 Posts
rswyatt is an unknown quantity at this point
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
rswyatt is offline   Reply With Quote
Old 01-09-2013, 10:59 PM   PM User | #2
TFlan
New Coder

 
Join Date: Dec 2012
Location: USA
Posts: 82
Thanks: 3
Thanked 17 Times in 17 Posts
TFlan is an unknown quantity at this point
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-09-2013 at 11:05 PM..
TFlan is offline   Reply With Quote
Old 01-09-2013, 11:19 PM   PM User | #3
tracknut
Regular Coder

 
Join Date: Aug 2006
Posts: 892
Thanks: 4
Thanked 206 Times in 205 Posts
tracknut is an unknown quantity at this point
You would add 0.005 before rounding. .6201+.005 = .6351, which rounds up to .63

Dave
tracknut is offline   Reply With Quote
Old 01-10-2013, 02:06 PM   PM User | #4
hinch
Regular Coder

 
hinch's Avatar
 
Join Date: Sep 2005
Location: UK
Posts: 921
Thanks: 25
Thanked 79 Times in 79 Posts
hinch is on a distinguished road
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
hinch is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:02 PM.


Advertisement
Log in to turn off these ads.