Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Why Round like this?

Why Round like this?

Scheduled Pinned Locked Moved C#
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rbuchana
    wrote on last edited by
    #1

    From the docs the definition of Math.Round The integer nearest a. If a is halfway between two integers, one of which is even and the other odd, then the even number is returned. So 4.5 rounds to 4 and 3.5 rounds to 4. Why?

    P T 3 Replies Last reply
    0
    • R rbuchana

      From the docs the definition of Math.Round The integer nearest a. If a is halfway between two integers, one of which is even and the other odd, then the even number is returned. So 4.5 rounds to 4 and 3.5 rounds to 4. Why?

      P Offline
      P Offline
      Peter Vertes
      wrote on last edited by
      #2

      Because it uses the Banker's Rounding algorithm to do the rounding. It's overrideable so you can use your own round method(s).

      --- http://iheartdotnet.blogspot.com

      1 Reply Last reply
      0
      • R rbuchana

        From the docs the definition of Math.Round The integer nearest a. If a is halfway between two integers, one of which is even and the other odd, then the even number is returned. So 4.5 rounds to 4 and 3.5 rounds to 4. Why?

        P Offline
        P Offline
        Peter Vertes
        wrote on last edited by
        #3

        I forgot to post the link with my previous post: http://en.wikipedia.org/wiki/Rounding[^]

        --- http://iheartdotnet.blogspot.com

        1 Reply Last reply
        0
        • R rbuchana

          From the docs the definition of Math.Round The integer nearest a. If a is halfway between two integers, one of which is even and the other odd, then the even number is returned. So 4.5 rounds to 4 and 3.5 rounds to 4. Why?

          T Offline
          T Offline
          TJoe
          wrote on last edited by
          #4

          I learned banker's rounding in High school, so it just seems natural to me. Check out this[^].

          Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups