Rounding Numbers in queries

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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?
 
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.
 
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.
 
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
 
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:
 
Back
Top