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. The Lounge
  3. Rounding

Rounding

Scheduled Pinned Locked Moved The Lounge
questionlounge
30 Posts 13 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.
  • P Offline
    P Offline
    PaulowniaK
    wrote on last edited by
    #1

    A very random question, but CPians' answers may possibly be useful for me... Is there a word or a phrase describing this:

    1.5 gets rounded to 1.
    1.6 gets rounded to 2.

    150 gets rounded to 100.
    160 gets rounded to 200.

    and any other similar effects...

    :confused: Any suggestions greatly appreciated.

    Almost, but not quite, entirely unlike... me...

    A P J L B 9 Replies Last reply
    0
    • P PaulowniaK

      A very random question, but CPians' answers may possibly be useful for me... Is there a word or a phrase describing this:

      1.5 gets rounded to 1.
      1.6 gets rounded to 2.

      150 gets rounded to 100.
      160 gets rounded to 200.

      and any other similar effects...

      :confused: Any suggestions greatly appreciated.

      Almost, but not quite, entirely unlike... me...

      A Offline
      A Offline
      Agent__007
      wrote on last edited by
      #2

      I am not sure what you mean by "a phrase", but there's an overload [^] for Math.Round() method to tweak this behavior. [EDIT] Sorry, didn't notice:

      PaulowniaK wrote:

      150 gets rounded to 100. 160 gets rounded to 200.

      What type of application are you trying to write? :confused: [/EDIT]

      Whether I think I can, or think I can't, I am always bloody right!

      P 1 Reply Last reply
      0
      • P PaulowniaK

        A very random question, but CPians' answers may possibly be useful for me... Is there a word or a phrase describing this:

        1.5 gets rounded to 1.
        1.6 gets rounded to 2.

        150 gets rounded to 100.
        160 gets rounded to 200.

        and any other similar effects...

        :confused: Any suggestions greatly appreciated.

        Almost, but not quite, entirely unlike... me...

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Are you directing those extra pennies to your own account?

        P 1 Reply Last reply
        0
        • P PIEBALDconsult

          Are you directing those extra pennies to your own account?

          P Offline
          P Offline
          PaulowniaK
          wrote on last edited by
          #4

          If only! ;P

          Almost, but not quite, entirely unlike... me...

          1 Reply Last reply
          0
          • A Agent__007

            I am not sure what you mean by "a phrase", but there's an overload [^] for Math.Round() method to tweak this behavior. [EDIT] Sorry, didn't notice:

            PaulowniaK wrote:

            150 gets rounded to 100. 160 gets rounded to 200.

            What type of application are you trying to write? :confused: [/EDIT]

            Whether I think I can, or think I can't, I am always bloody right!

            P Offline
            P Offline
            PaulowniaK
            wrote on last edited by
            #5

            I'm not able to disclose application details, but let's just say, the said behaviour already exists. The trouble is how I would go about explaining what it's doing to the users. Writing in the Help that "it rounds to the nearest integer" or "it rounds to the nearest 100" automatically suggests it does this:

            1.4 turns into 1.
            1.5 turns into 2.
            1.6 turns into 2.

            140 turns into 100.
            150 turns into 200.
            160 turns into 200.

            etc. etc.

            which isn't what happens. Sure, I can explain this long hand, but I just wanted to know if there was a proper terminology to explain this.

            Almost, but not quite, entirely unlike... me...

            S 1 Reply Last reply
            0
            • P PaulowniaK

              I'm not able to disclose application details, but let's just say, the said behaviour already exists. The trouble is how I would go about explaining what it's doing to the users. Writing in the Help that "it rounds to the nearest integer" or "it rounds to the nearest 100" automatically suggests it does this:

              1.4 turns into 1.
              1.5 turns into 2.
              1.6 turns into 2.

              140 turns into 100.
              150 turns into 200.
              160 turns into 200.

              etc. etc.

              which isn't what happens. Sure, I can explain this long hand, but I just wanted to know if there was a proper terminology to explain this.

              Almost, but not quite, entirely unlike... me...

              S Offline
              S Offline
              Steve Wellens
              wrote on last edited by
              #6

              How's this: Round to one significant digit.

              A D 2 Replies Last reply
              0
              • P PaulowniaK

                A very random question, but CPians' answers may possibly be useful for me... Is there a word or a phrase describing this:

                1.5 gets rounded to 1.
                1.6 gets rounded to 2.

                150 gets rounded to 100.
                160 gets rounded to 200.

                and any other similar effects...

                :confused: Any suggestions greatly appreciated.

                Almost, but not quite, entirely unlike... me...

                J Offline
                J Offline
                Jorgen Andersson
                wrote on last edited by
                #7

                Rounding to one significant digit.

                Wrong is evil and must be defeated. - Jeff Ello[^]

                P 1 Reply Last reply
                0
                • P PaulowniaK

                  A very random question, but CPians' answers may possibly be useful for me... Is there a word or a phrase describing this:

                  1.5 gets rounded to 1.
                  1.6 gets rounded to 2.

                  150 gets rounded to 100.
                  160 gets rounded to 200.

                  and any other similar effects...

                  :confused: Any suggestions greatly appreciated.

                  Almost, but not quite, entirely unlike... me...

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  http://en.wikipedia.org/wiki/Rounding[^] "Round half down to nearest integral multiplier power of 10"

                  Peter Wasser "The whole problem with the world is that fools and fanatics are always so certain of themselves, and wiser people so full of doubts." - Bertrand Russell

                  P 1 Reply Last reply
                  0
                  • S Steve Wellens

                    How's this: Round to one significant digit.

                    A Offline
                    A Offline
                    Agent__007
                    wrote on last edited by
                    #9

                    :thumbsup: Considering he needs 160.6 to be rounded to 200 and not 161.

                    Whether I think I can, or think I can't, I am always bloody right!

                    1 Reply Last reply
                    0
                    • P PaulowniaK

                      A very random question, but CPians' answers may possibly be useful for me... Is there a word or a phrase describing this:

                      1.5 gets rounded to 1.
                      1.6 gets rounded to 2.

                      150 gets rounded to 100.
                      160 gets rounded to 200.

                      and any other similar effects...

                      :confused: Any suggestions greatly appreciated.

                      Almost, but not quite, entirely unlike... me...

                      B Offline
                      B Offline
                      BillWoodruff
                      wrote on last edited by
                      #10

                      how I would go about explaining what it's doing to the users.

                      If you owe us money, we get more; if we owe you money, you get less.

                      “I have diligently numbered the days of pure and genuine happiness which have fallen to my lot: They amount to 14.” Abd-Ar Rahman III, Caliph of Cordoba, circa 950CE.

                      1 Reply Last reply
                      0
                      • P PaulowniaK

                        A very random question, but CPians' answers may possibly be useful for me... Is there a word or a phrase describing this:

                        1.5 gets rounded to 1.
                        1.6 gets rounded to 2.

                        150 gets rounded to 100.
                        160 gets rounded to 200.

                        and any other similar effects...

                        :confused: Any suggestions greatly appreciated.

                        Almost, but not quite, entirely unlike... me...

                        J Offline
                        J Offline
                        JMK NI
                        wrote on last edited by
                        #11

                        This is standard rounding The irony is that people are so used to bankers rounding they get confused when they see ordinary rounding, but this is the kind you probably learned about in school! Disregard, I'm an idiot

                        D B 2 Replies Last reply
                        0
                        • P PaulowniaK

                          A very random question, but CPians' answers may possibly be useful for me... Is there a word or a phrase describing this:

                          1.5 gets rounded to 1.
                          1.6 gets rounded to 2.

                          150 gets rounded to 100.
                          160 gets rounded to 200.

                          and any other similar effects...

                          :confused: Any suggestions greatly appreciated.

                          Almost, but not quite, entirely unlike... me...

                          D Offline
                          D Offline
                          DaveAuld
                          wrote on last edited by
                          #12

                          Smells very much like "Significant Number Rounding"... http://en.wikipedia.org/wiki/Significant_figures[^] Demo Calculator -> http://ostermiller.org/calc/significant_figures.html[^]

                          Dave Find Me On:Web|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                          P 1 Reply Last reply
                          0
                          • J JMK NI

                            This is standard rounding The irony is that people are so used to bankers rounding they get confused when they see ordinary rounding, but this is the kind you probably learned about in school! Disregard, I'm an idiot

                            D Offline
                            D Offline
                            DaveAuld
                            wrote on last edited by
                            #13

                            JMK-NI wrote:

                            This is standard rounding

                            No it isn't. There is a huge difference between standard rounding and significant rounding. There are also many different types of rounding scheme depending on the application: http://en.wikipedia.org/wiki/Rounding[^]

                            Dave Find Me On:Web|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                            J 1 Reply Last reply
                            0
                            • D DaveAuld

                              JMK-NI wrote:

                              This is standard rounding

                              No it isn't. There is a huge difference between standard rounding and significant rounding. There are also many different types of rounding scheme depending on the application: http://en.wikipedia.org/wiki/Rounding[^]

                              Dave Find Me On:Web|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                              J Offline
                              J Offline
                              JMK NI
                              wrote on last edited by
                              #14

                              Well knock me down! It's 6:30AM, I haven't had coffee yet!

                              D 1 Reply Last reply
                              0
                              • J Jorgen Andersson

                                Rounding to one significant digit.

                                Wrong is evil and must be defeated. - Jeff Ello[^]

                                P Offline
                                P Offline
                                PaulowniaK
                                wrote on last edited by
                                #15

                                OK, bad example...

                                123 would be 120.
                                125 would be 120.
                                126 would be 130.

                                etc. etc.

                                The point not being the number of significant digits you end up with, but the fact that the rounding is happening at 5 and 6 rather than the more usual 4 and 5.

                                Almost, but not quite, entirely unlike... me...

                                D J G 3 Replies Last reply
                                0
                                • J JMK NI

                                  Well knock me down! It's 6:30AM, I haven't had coffee yet!

                                  D Offline
                                  D Offline
                                  DaveAuld
                                  wrote on last edited by
                                  #16

                                  Well it's now 6:43am, my first meeting with my supervisory team was an hour ago and I have already spoken with my boss onshore, so the day is well underway. Only another 14 or 15 hours still to go. :doh: Feeling :zzz: already.

                                  Dave Find Me On:Web|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                                  1 Reply Last reply
                                  0
                                  • D DaveAuld

                                    Smells very much like "Significant Number Rounding"... http://en.wikipedia.org/wiki/Significant_figures[^] Demo Calculator -> http://ostermiller.org/calc/significant_figures.html[^]

                                    Dave Find Me On:Web|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                                    P Offline
                                    P Offline
                                    PaulowniaK
                                    wrote on last edited by
                                    #17

                                    My understanding of rounding to N significant figure is like this:

                                    1234 to 3 significant figures = 1230
                                    1235 to 3 significant figures = 1240
                                    1236 to 3 significant figures = 1240

                                    The trouble is, I need

                                    1234 to 3 significant figures = 1230
                                    1235 to 3 significant figures = 1230
                                    1236 to 3 significant figures = 1240

                                    The point is, rather than rounding up or down depending on whether the N+1th digit is 4 or 5, but whether it is 5 or 6.

                                    Almost, but not quite, entirely unlike... me...

                                    D A J 3 Replies Last reply
                                    0
                                    • P PaulowniaK

                                      OK, bad example...

                                      123 would be 120.
                                      125 would be 120.
                                      126 would be 130.

                                      etc. etc.

                                      The point not being the number of significant digits you end up with, but the fact that the rounding is happening at 5 and 6 rather than the more usual 4 and 5.

                                      Almost, but not quite, entirely unlike... me...

                                      D Offline
                                      D Offline
                                      DaveAuld
                                      wrote on last edited by
                                      #18

                                      Sounds like you want to do Round Half Down + Significant then.

                                      Dave Find Me On:Web|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                                      1 Reply Last reply
                                      0
                                      • P PaulowniaK

                                        My understanding of rounding to N significant figure is like this:

                                        1234 to 3 significant figures = 1230
                                        1235 to 3 significant figures = 1240
                                        1236 to 3 significant figures = 1240

                                        The trouble is, I need

                                        1234 to 3 significant figures = 1230
                                        1235 to 3 significant figures = 1230
                                        1236 to 3 significant figures = 1240

                                        The point is, rather than rounding up or down depending on whether the N+1th digit is 4 or 5, but whether it is 5 or 6.

                                        Almost, but not quite, entirely unlike... me...

                                        D Offline
                                        D Offline
                                        DaveAuld
                                        wrote on last edited by
                                        #19

                                        Round half down + Significant.

                                        Dave Find Me On:Web|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject

                                        P 1 Reply Last reply
                                        0
                                        • P PaulowniaK

                                          My understanding of rounding to N significant figure is like this:

                                          1234 to 3 significant figures = 1230
                                          1235 to 3 significant figures = 1240
                                          1236 to 3 significant figures = 1240

                                          The trouble is, I need

                                          1234 to 3 significant figures = 1230
                                          1235 to 3 significant figures = 1230
                                          1236 to 3 significant figures = 1240

                                          The point is, rather than rounding up or down depending on whether the N+1th digit is 4 or 5, but whether it is 5 or 6.

                                          Almost, but not quite, entirely unlike... me...

                                          A Offline
                                          A Offline
                                          Agent__007
                                          wrote on last edited by
                                          #20

                                          How about "N Significant Half-Down Rounding[^]"?

                                          Whether I think I can, or think I can't, I am always bloody right!

                                          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