rounding number

  • Thread starter Thread starter wayne wu
  • Start date Start date
W

wayne wu

I am using Access 2000 version. When I try to ROUND the
decimal number such as .305 to two digits it returns .30
instead .31. It happens to .325,.345,.365 ....but didn't
happen to .315,335,355....
Am I doing something wrong? My e-mail is
(e-mail address removed)

Round(.305,2) returns .30
 
wayne wu said:
I am using Access 2000 version. When I try to ROUND the
decimal number such as .305 to two digits it returns .30
instead .31. It happens to .325,.345,.365 ....but didn't
happen to .315,335,355....
Am I doing something wrong? My e-mail is
(e-mail address removed)

I strongly advise you *not* to post your real e-mail address in the
newsgroups. Not only do spammers harvest addresses from the newsgroups,
but viruses do, too.
Round(.305,2) returns .30

This behavior, as the 'softies like to say, is by design. Access uses
"banker's rounding", which means that it rounds the digit 5 toward the
nearest even value. The object is to minimize bias due to rounding
error. If you don't want it to do this, you have to write your own
rounding function, or get one of the many that have been posted in the
newsgroups and on the web.
 
I am using Access 2000 version. When I try to ROUND the
decimal number such as .305 to two digits it returns .30
instead .31. It happens to .325,.345,.365 ....but didn't
happen to .315,335,355....
Am I doing something wrong?

Nothing at all. This is how the Round() function works, and how it's
documented to work. It's called "Banker's Rounding" - a 5 one past the
round point rounds to the nearest EVEN number. Greater than 5 rounds
up, less than five rounds down, 5 rounds up half the time and down
half the time; this makes the sum or average of the rounded values
closer to the sum or average of the unrounded values, rather than
greater (as would happen if 5 always rounded up).
My e-mail is
(e-mail address removed)

Private EMail support is for paying customers. Ask here, get the
answer here!
 
The easy solution I normally use is to add a tiny Bias (*too small to affect
the real result but big enough to push the rounding up*). For example, if
you work with 3 decimal places, use Bias = 0.0001 and the 5 in the 3rd
decimal place will always get rounded up.

Experiment and see what the suitable value for Bias to suit your data type
and your usage.
 
Back
Top