Rounding Numbers in queries

G

Guest

I have several queries which perform divisions requiring rounnding. When the
digit rounded is a 5, if the digit to the left is odd it rounds up and if the
digit to the left is even, it rounds down. Is there a work-arround in a
query for addressing this issue ?

? round(1.5)
2

? round(2.5)
2
 
R

Randy Harris

rmcompute said:
I have several queries which perform divisions requiring rounnding. When the
digit rounded is a 5, if the digit to the left is odd it rounds up and if the
digit to the left is even, it rounds down. Is there a work-arround in a
query for addressing this issue ?

? round(1.5)
2

? round(2.5)
2

What would you prefer as an alternative?
 
D

Douglas J. Steele

It's known as Banker's Rounding, and it's done deliberately, as it's
supposed to reduce round-off error when summing large lists of numbers.

For anything else, you'll need to write your own Rounding routine.
 
J

John Spencer

You can add a very small number to the value before rounding it.

Round(1.5 + .000000001) will round to 2
Round(2.5 + .000000001) will round to 3

Other methods are available, but they are written using VBA and are not built in.
 
M

Michel Walsh

Hi,


int( yourNumber + CDec(0.5) )


should "round" up if the decimal portion of your number is from .5 or more
(for positive numbers, check if the behavior fits your need for negative
numbers).



Hoping it may help,
Vanderghast, Access MVP
 
H

Hilde

Hi,

I have spent 2 days reading all the treads concerning rounding up/down (need
to round up .5) and I've tested most of the suggestions without luck. But
here's the answer genious in all it's simplicity!

"John Spencer" skrev:
 

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