Rounding Problem

S

stetat

I am having problems with the results of calculations i am
doing. I am trying to round the result down to the nearest
single number using the below formula which works fine
with positive numbers, but with negative numbers it round
up (eg -1.923 to -2)

intNewValue = Int(Value1/Value2)

Can anyone help

Thank You
 
V

Van T. Dinh

Mathematically, rounding -1.923 to -2 is rounding *down* since -2 is less
than -1.923.

It sounds like you want to use the Fix() function rather than the Int()
function.

?Fix(1.923)
1
(same as Int() for positive numbers)

?Fix(-1.923)
-1
(different from Int() for negative numbers)
 

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