Rounding number

B

Boon

Hello,

I would like to know what function in Access that would perform exactly the
same as function Round() in Excel. In excel I use function, for instance,
=Round(A1,2). For rounding to 2 decimal place.

Thanks,
Boon
 
G

golfinray

Sorry, I think you can also do Round([yourfield],2) if you want a specified
round.
 
B

Boon

No, that doesn't work. I have been told to use int() but I don't know how to
use it.

Thanks.
golfinray said:
Sorry, I think you can also do Round([yourfield],2) if you want a
specified
round.
--
Milton Purdy
ACCESS
State of Arkansas


Boon said:
Hello,

I would like to know what function in Access that would perform exactly
the
same as function Round() in Excel. In excel I use function, for instance,
=Round(A1,2). For rounding to 2 decimal place.

Thanks,
Boon
 
K

KARL DEWEY

What is wrong with the resulsts from the expression Round([yourfield],2) ?
Post the orignal number, results, and expected results.

--
Build a little, test a little.


Boon said:
No, that doesn't work. I have been told to use int() but I don't know how to
use it.

Thanks.
golfinray said:
Sorry, I think you can also do Round([yourfield],2) if you want a
specified
round.
--
Milton Purdy
ACCESS
State of Arkansas


Boon said:
Hello,

I would like to know what function in Access that would perform exactly
the
same as function Round() in Excel. In excel I use function, for instance,
=Round(A1,2). For rounding to 2 decimal place.

Thanks,
Boon
 
V

vanderghast

Rounding down to two decimal place (100) :

int(CDec(100) * x ) / 100

Rounding to the nearest 'integer' to two decimal places:

int(0.5 + CDec(100)*x) / 100

Rounding up to two decimal places:

-int(-CDec(100)*x)/100


All those assume x >= 0.
Using CDec(100) bring the minimum internal representation error while
processing the multiplication.



Vanderghast, Access MVP




Boon said:
No, that doesn't work. I have been told to use int() but I don't know how
to use it.

Thanks.
golfinray said:
Sorry, I think you can also do Round([yourfield],2) if you want a
specified
round.
--
Milton Purdy
ACCESS
State of Arkansas


Boon said:
Hello,

I would like to know what function in Access that would perform exactly
the
same as function Round() in Excel. In excel I use function, for
instance,
=Round(A1,2). For rounding to 2 decimal place.

Thanks,
Boon
 
J

John W. Vinson

No, that doesn't work. I have been told to use int() but I don't know how to
use it.

Round() does indeed work when used correctly.

What's the datatype of the field? What exact expression are you using? In what
context (in a Query, on a Form, or what?)
 
J

John W. Vinson

Hello,

I would like to know what function in Access that would perform exactly the
same as function Round() in Excel. In excel I use function, for instance,
=Round(A1,2). For rounding to 2 decimal place.

Thanks,
Boon

Are you perhaps (without saying so, leaving it to intuition to divine)
concerned about the difference between "Banker's Rounding" - a 5 in the last
place rounds to the nearest even digit - and "Arithmatic Rounding" - a 5
always rounds up?
 
B

Boon

I saw that round() did not do the arithmetic rounding. It does banker's
rounding which is not what I want.
 
K

KARL DEWEY

My Access 2007 rounds like Excel --
xx Expr1
1.5 1.5
1.001 1
5.0008 5
1.555 1.56
1.556 1.56
1.545 1.54
1.546 1.55

Post your numbers.

--
Build a little, test a little.


Boon said:
I saw that round() did not do the arithmetic rounding. It does banker's
rounding which is not what I want.
 
J

John Spencer

Did you try rounding 1.565? If things remain the same with the round
function, you should get 1.56 and not the expected 1.57

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
K

KARL DEWEY

Expr1: Round([xx],2)

xx Expr1
1.001 1
5.0008 5
1.555 1.56
1.556 1.56
1.545 1.54
1.546 1.55
1.565 1.56

I just noticed that if the 2nd place is 5 then the 3rd place causing a round
up where 3rd is 5.
If the 2nd place is 4 then the 3rd place causing a round down where 3rd is 5.
 
J

John Spencer

Well, that article specifically says it is using Banker's rounding.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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

Top