in vb6, round off value with 0 precision for the numbers 325756.50, 327336.50 & 318646.50 shows as 325756,327336 & 318646. Oth

raghulmsc

Estimable
Jan 5, 2015
2
0
4,510
in vb6, round off value with 0 precision for the numbers 325756.50, 327336.50 & 318646.50 shows as 325756,327336 & 318646.
Other languages shows as 325757, 327337 & 318647. any one can explain? why?
 
Solution
Just because of how they have it set up?

Technically speaking, both sets of answers are 100% correct. It just depends on the tie-braking rule you prefer to use:
-- "rounding half up" always increases the number to the next positive integer (i.e. 3.5 becomes 4, -3.5 becomes -3, etc.).
-- "rounding half down" always decreases the number to the next positive integer (i.e. 3.5 becomes 3, -3.5 becomes -4, etc.).
-- "rounding half away from zero" moves the integer farther from the zero point (i.e. 3.5 becomes 4, -3.5 becomes -4, etc.).
-- "rounding half towards zero" moves it closer to the zero point (i.e. 3.5 becomes 3, -3.5 becomes -3, etc.).
-- "round half to even" moves it to the closest even integer (i.e. 3.5 and 4.5 both round to...

spdragoo

Distinguished
Herald
Oct 17, 2011
186
0
18,910
Just because of how they have it set up?

Technically speaking, both sets of answers are 100% correct. It just depends on the tie-braking rule you prefer to use:
-- "rounding half up" always increases the number to the next positive integer (i.e. 3.5 becomes 4, -3.5 becomes -3, etc.).
-- "rounding half down" always decreases the number to the next positive integer (i.e. 3.5 becomes 3, -3.5 becomes -4, etc.).
-- "rounding half away from zero" moves the integer farther from the zero point (i.e. 3.5 becomes 4, -3.5 becomes -4, etc.).
-- "rounding half towards zero" moves it closer to the zero point (i.e. 3.5 becomes 3, -3.5 becomes -3, etc.).
-- "round half to even" moves it to the closest even integer (i.e. 3.5 and 4.5 both round to 4, -3.5 and -4.5 both round to -4, etc.).
-- "round half to odd" is similar, just moving it to the nearest odd integer (i.e. 3.5 rounds to 3, 4.5 rounds to 5, -3.5 rounds to -3, -4.5 rounds to -5, etc.).

There are even 2 other tie-breaking methods, "stochastic" and "alternating", where the rounding method switches between 1 of 2 paired options (randomly or alternating).

So, as a guess, the round off function in VB6 is using either "round half down" or "round half to zero", with the other languages using "round half up" or "round half away from zero". Since the documentation probably mentions that it does this, you should have no trouble accounting for it.
 
Solution