Results 1 to 10 of 10

Thread: What is nearest 10th of 25?

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    What is nearest 10th of 25?

    Is it 20 or 30?
    Baaaaaaaaah

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    30

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Maybe this should go in the Math forum
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Thanks, I was just curious about 5...I always have that confusion.
    Baaaaaaaaah

  5. #5
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    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.

  6. #6
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    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.

  7. #7

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    it is just rounding to the nearest 10th. I am writing a function that does that.
    Baaaaaaaaah

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    VB has a rounding function named Round that uses banker's rounding (rounding .5 to nearest even number).
    You can use that:
    VB Code:
    1. Public Function RoundToTen(num As Single) As Single
    2.     RoundToTen=Round(num / 10) * 10
    3. End Function
    Best regards

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Or if you want to use arithmetic rounding:
    VB Code:
    1. Public Function RoundToTen(num As Single) As Integer
    2.     RoundToTen=Int(num / 10 + .5) * 10
    3. End Function
    Best regards

  10. #10

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I am doing it in Turing, not vb
    Baaaaaaaaah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width