Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

1 cent difference. ? Calculation error?

Status
Not open for further replies.

vast02

IS-IT--Management
Jul 21, 2005
7
US
I have one form in my project to calculate the Change from what a customer paid. There are fields of Subtotal, Tax, Total, Paid and Change. All the fields are set in Currency format. My users complain there is 1 cent difference in the Change field from the computer calculation occasionally. Here is the real example:

Subtotal: $47.50
Tax (5%): $2.38
Total: $49.88
Paid: $50
Change: $0.13

I know the problem is because of the round up in the Tax field (2.375 ---> 2.38). However, from the view point of users, they fell hte computer calculating it wrong. The change should be 0.12, instead of 0.13. I understand what they feel.

Is there any code I can command the Change field be calculate directly as (50-49.88)= 0.12 instead (50-49.875)
=0.125 --> and end up to be rounded up as 0.13?

I appreciate your help.

Vast
 


Hi,

My version of Access does not have a CURRENCY number. It does have DECIMAL, which is what I would suggest.
Stores numbers from -10^38 -1 through 10^38 -1 (.adp)
Stores numbers from-10^28 -1 through 10^28 -1
My guess is that the data type you have is SINGLE or DOUBLE which will bite you in the butt.


Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Have you tried to explicitely use the Round function ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You need to compute taxes correctly.

The tax should be exactly $2.38 ... not $2.375 that just appears as $2.38 because of the formatting. Most tax regimes want the final tax amount to be a whole number of cents with no fractions of a cent.

Compute taxes as Taxes = Round(Taxes,2) before you add it to the SubTotal or compute the change.
 
Hi, How do I use the Round function explicitely?

vast
 
In pseudo-code:

change=paid-subtotal-roundup(subtotal*tax,2)

If you post your actual statement, someone will certainly assist.

HTH,
Bob [morning]
 
How do I use the Round function explicitly?
Say you actually have:
[Tax] = [Subtotal] * 0.05
Replace it with:
[Tax] = Round([Subtotal] * 0.05, 2)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top