Using INT()

D

DS

Am I doing this correctly? This is for Tax Reasons.
Here is my example;
Int((NumberToRound * 100) + 0.5) / 100

Her is my Code
Me.TxtNoneTax = Int(Nz(DSum("(CDQuantity*CDFinalPrice)*CDTaxRate",
"tblCheckDetailsTMP", "CDCheckID = " & Forms!Form2!TxtCheckID & " AND
CDDiscountDP = 0"), 0) * 100 + 0.5) / 100

Thanks
DS
 
M

Marshall Barton

DS said:
Am I doing this correctly? This is for Tax Reasons.
Here is my example;
Int((NumberToRound * 100) + 0.5) / 100

Her is my Code
Me.TxtNoneTax = Int(Nz(DSum("(CDQuantity*CDFinalPrice)*CDTaxRate",
"tblCheckDetailsTMP", "CDCheckID = " & Forms!Form2!TxtCheckID & " AND
CDDiscountDP = 0"), 0) * 100 + 0.5) / 100


That will do your basic elementary school type of rounding.
However, you should make sure that's what you want when
NumberToRound is negative.

You should also be aware that it is not as accurate as the
built in Round function over a set of such values.
 
D

DS

I guess I do want the basic rounding, the problem with the round function is
that it isn't great when it comes to taxes, this seems to be working fine
for now. Thanks
DS
 
D

DS

Hi Marsh,
What did you mean Round To Negative? What part of the code does that? And
if I wanted to Rount To Positive how would I do that?
Thanks, I appreciate the input.
DS
 
M

Marshall Barton

DS said:
What did you mean Round To Negative? What part of the code does that? And
if I wanted to Rount To Positive how would I do that?


I didn't say "Round To Negative". I ask what you want to
happen IF the value is negative. I.e. do you want -2.345 to
round to -2.34 or to -2.35?

Your expression produces:
NumberToRound Result
2.345 2.35
-2.345 -2.34
which can also be achieved by the slightly simpler
expression:
-Int(-NumberToRound * 100) / 100

On the other hand:
Fix(NumberToRound * 100 + Sgn(NumberToRound ) * .5) / 100
produces:
NumberToRound Result
2.345 2.35
-2.345 -2.35

The point I'm trying to make is that rounding makes a value
less exact than the original and it can be very important
what kind of error factor the expression introduces. In the
case of a tax calculation, government rules will apply and
you must understand how well your expression adheres to
those rules.
 
D

DS

Thanks Marsh,
After looking into it I've decided to use the Round() set to 2 . There's an
article about it by Allen Browne, it's called Bankers Rounding. So if it's
good enough for a bank, I guess it will do for me.
Thanks
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Line Break 9
Function Returns 0 3
Two D Statemnets 4
Form Reference 5
DSum Problem 2
Union Query Format 6
SQL ORDER BY 1
Argument Not Optional 3

Top