how to round?

G

Guest

hi there!


my question is how to round the numbers in decimal place.

for example:
i want to round this
-7.06
and i want to the output to be:
-7.0
is there any way to round this to ms access.
please help me.
 
J

John Vinson

hi there!


my question is how to round the numbers in decimal place.

for example:
i want to round this
-7.06
and i want to the output to be:
-7.0
is there any way to round this to ms access.
please help me.

Round(<some expression>, 1)

will round to one decimal place.

John W. Vinson[MVP]
 
G

Guest

yeah i know that function but if you use that for example

round(-7.06,1) = -7.1

i don't want that to be the output

i want the output to be like this -7.0

i don't want to round the .0
 
G

Gary Walter

chad said:
my question is how to round the numbers in decimal place.

for example:
i want to round this
-7.06
and i want to the output to be:
-7.0

Pardon me for butting in...

it sounds like you are asking for truncation?

- move the decimal point over 1 place

-7.06 * 10 = -70.6

- then truncate anything on right of decimal point

Fix(-70.6) = -70

- move decimal point back 1 place

-70/10.0 = -7.0

so, rounding formula I believe you are looking for...

Fix(yurnumber * 10) / 10.0

Note how you could change the "multiplier/divisor"
that move the decimal point to truncate at different
places within the decimal part of the number...

Why we used Fix() instead of Int() for negative
numbers is explained in this old link
http://support.microsoft.com/default.aspx?scid=kb;en-us;196652
 
J

John Vinson

i don't want that to be the output

i want the output to be like this -7.0

i don't want to round the .0

Sorry. I answered the question THAT YOU ASKED:
my question is how to round the numbers in decimal place.

My apologies that I was unable to intuit that it wasn't the question
that you *meant* to ask.

Since you want to truncate (and not to round), Gary's solution is
perfect.

John W. Vinson[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

Top