Problems regarding "Round" function 
Author Message
 Problems regarding "Round" function

In my software I've used syntax like:

X=round(I/2, 0)

I expect that if I = 19, then X will become 10 as I/2 is 9.5
However the software give me the X as 9.

What should i do if I wan to have X = 10?

Regards,
Derek



Wed, 18 Jun 1902 08:00:00 GMT  
 Problems regarding "Round" function
I would like to activate the character table, which is a software comes with
MS windows. What string should i add into the code so to activate it?

regards,
Derek



Wed, 18 Jun 1902 08:00:00 GMT  
 Problems regarding "Round" function

released on Wed, 6 Dec 2000 15:43:15 +0800 bearing the
following fruit:

Quote:
>In my software I've used syntax like:

>X=round(I/2, 0)

>I expect that if I = 19, then X will become 10 as I/2 is 9.5
>However the software give me the X as 9.

>What should i do if I wan to have X = 10?

Round(19/2,0) = 10 on my machine.

However

Round(19\2,0) = 9

J



Wed, 18 Jun 1902 08:00:00 GMT  
 Problems regarding "Round" function
I agree with Jan.
Have a look in help for / and \, they're not the same.

--
Stephen Brooker

"Windows has detected that you have moved your mouse. You must restart for
this change to take effect."


Quote:
> In my software I've used syntax like:

> X=round(I/2, 0)

> I expect that if I = 19, then X will become 10 as I/2 is 9.5
> However the software give me the X as 9.

> What should i do if I wan to have X = 10?

> Regards,
> Derek



Wed, 18 Jun 1902 08:00:00 GMT  
 Problems regarding "Round" function
Visual Basic uses "bankers" rounding. This means that when the fractional part
is exactly 0.5 it "rounds up" if the whole part is odd and it "rounds down" if
the whole part is even. This minimises "unfair bias".

For example, try:

Print Round(9.5, 0)
Print Round(10.5, 0)

Since you are only dealing in "whole number" answers then you can use the Int
function instead. The Int function does not use this "bankers" stuff and when
the fractional part is exactly 0.5 then it always rounds down, regardless of
whether the "whole" part is odd or even.

In your case you want to always "round up". You can do this (in your case using
either method) by simply adding a tiny bit to the original number in your
equation (unless there is an easier way to do this that I have missed, which
would not be unusual!).

Mike


Quote:
> In my software I've used syntax like:

> X=round(I/2, 0)

> I expect that if I = 19, then X will become 10 as I/2 is 9.5
> However the software give me the X as 9.

> What should i do if I wan to have X = 10?

> Regards,
> Derek



Wed, 18 Jun 1902 08:00:00 GMT  
 Problems regarding "Round" function
Shell "charmap", vbNormalFocus


Quote:
> I would like to activate the character table, which is a software comes with
> MS windows. What string should i add into the code so to activate it?

> regards,
> Derek



Wed, 18 Jun 1902 08:00:00 GMT  
 Problems regarding "Round" function
It will be a hard work. I think you should check that the fix(number) and
the int(number) do not return the same number for -9.5. You should also work
with \.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Problem With "window.showmodaldialog("")"

2. Question regarding "Session" command

3. Question regarding "cjb.net"

4. Newbie question regarding "limiting" code

5. Question regarding "cjb.net"

6. Question regarding "cjb.net"

7. DatePart Function "yy" problem

8. "Function address" problem

9. I have problem using function "Shell"

10. Problems with the "Now" function

11. Problems with "DIR" function

12. Problem with "Open" function

 

 
Powered by phpBB® Forum Software