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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to round to 2 decimal places in a Form

Status
Not open for further replies.

Grunster

Technical User
Oct 26, 2003
4
0
0
GB
Can somebody please help me with this problem.

I am doing what I think is a simple calculation of 3 percentages. 3.25% - 0% - 0%.

For some reason this seems to keep giving me the result of 3.249999. This then gives me a wrong calculation when using this percentage against a currency amount.

I have been trying to work out why it is returning this figure and why I can't round it up to 3.25% to calculate it against a currency amount.

Any help on this would be very much appreciated and also save my sanity.

Thanks

Grant
 
Are the three values being input or are they the result of calculations?
I'm guessing calculations.
If so then you cannot be certain that the displayed result is the stored value, unless you use a technique which makes it so.


 
The 3 values are being pulled from 3 seperate tables.

The problem has slightly evolved since I posted this is that I have managed to get the percentages to show 3.25% after the calculations have been done.

The problem I have now is the with the following figures:
I have a Gross amount of £1,750. I need to know the net amount after charges and the charge (which is 3.25%).

3.25% of £1750 is £56.875 (£56.88 rounded)
£56.875 minus £1,750 is £1,693.125 (£1,693.13 rounded)
When the 2 rounded figures are added you end up with £1,750.01 1 pence extra.

I am trying to find a function similar to the 'round' function in Exel which doesn't just format the result to 2 decimal places but actually converts the result into a whole figure to 2 decimal places.

Thanks

Grant
 
Something like this ?
=Format([calculated field], "0.00")+0

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Given that 3.25% of £1750 is £56.875 then it is a matter of opinion or convention or sometimes law about whether this is 56.87 or 56.88 when expressed to 2dp.
You can make calculations do the rounding in the way you want them to but, as you have identified in Excel, formatting is not the same as rounding.

In the case you are talking about, then I think you have established that you must round the first result before subtracting it from the total.
You could do this by:
int(percent * value *100)/100
or
int(percent * value *100+.5)/100
depending on how you want the rounding to work.

What you can never do in any situation where a series of calculated values must be forced to add up to a predefined total is to calculate ALL the values independently. There will always be one value that must be calculated as :
predefined total - sum of the other calculations








 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top