ROUNDING OFF IN QUERIES

P

PATRICK

I WANT TO CALCULATE THE NETPAYABLE AFTER DEDUCTING 2%
(ROUNDED OFF TO THE NEXT HIGHER INTEGER) FROM [GROSS].MS
ACCESS ROUNDS OFF SOMETIMES TO THE HIGHER INTEGER AND
SOMETIMES TO THE LOWER.FOR [GROSS] EQUAL TO 825,875,925,975
ETC I GET WRONG RESULTS IN NET.FOR EXAMPLE ROUND(14.5,0)
GIVES 14 AND ROUND(15.5,0) GIVES 16.PLEASE HELP ME
PATRICK.
(e-mail address removed)
 
M

Michel Walsh

Hi,


Try not using all cap. That is harder to read (less space between the lines,
create more stress to the eyes) and it is clearly less comfortable.


You describe the "banking" rounding. If you would always round up, at 0.5,
on many transactions, you would end up with a lost of money. Having a round
down and a round up, at 0.5, when the integer is even or odd tends to zero
the sum of the "rounding" errors that would occur (in theory).

That being said, Int( ) will always truncate, so

Int(0.5+x)

will round up, at or part 0.5, as it seems what you want.

? int(0.5+ 2.45), int(0.5+14.5), int(0.5+15.5)
2 15 16



Check if it behaves as you wish for negative values, if not, try Fix( )
instead of Int( ).


Hoping it may help,
Vanderghast, Access MVP
 

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


Top