Is it 20 or 30?
Printable View
Is it 20 or 30?
30
Maybe this should go in the Math forum :p
Thanks, I was just curious about 5...I always have that confusion.
Here's a simple little rule:
Everything from 0-4 is rounded down (eg.: 4 becomes 0)
Everything from 5-9 is rounded up (eg.: 5 becomes 10)
That's just your everyday basic rounding rule. There's other types of rounding too.
Arithmetic Rounding
When rounding always down or up, the resulting number is not necessarily
the closest to the original number. For example, if you round 1.9 down to 1,
the difference is a lot larger than if you round it up to 2. It is easy to see
that numbers from 1.6 to 2.4 should be rounded to 2.
However, what about 1.5, which is equidistant between 1 and 2? By convention,
the half-way number is rounded up.
You can implement rounding half-way numbers in a symmetric fashion,
such that -.5 is rounded down to -1, or in an asymmetric fashion, where -.5 is
rounded up to 0.
Banker's Rounding
When you add rounded values together, always rounding .5 in the same
direction results in a bias that grows with the more numbers you add together.
One way to minimize the bias is with banker's rounding.
Banker's rounding rounds .5 up sometimes and down sometimes. The convention is to round to the nearest even number,
so that both 1.5 and 2.5 round to 2, and 3.5 and 4.5 both round to 4. Banker's rounding is symmetric.
it is just rounding to the nearest 10th. I am writing a function that does that.
VB has a rounding function named Round that uses banker's rounding (rounding .5 to nearest even number).
You can use that:Best regardsVB Code:
Public Function RoundToTen(num As Single) As Single RoundToTen=Round(num / 10) * 10 End Function
Or if you want to use arithmetic rounding:Best regardsVB Code:
Public Function RoundToTen(num As Single) As Integer RoundToTen=Int(num / 10 + .5) * 10 End Function
I am doing it in Turing, not vb;)