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. Being bad at math

Being bad at math

Scheduled Pinned Locked Moved The Lounge
questioncsharpdatabasewpfcom
73 Posts 33 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.
  • E Ennis Ray Lynch Jr

    Zero based indexes seem to be kicking programmer's A**es even today. I am recently using a software package that allows row styles to be applied for even and odd rows. If you apply an even style the 1st, 3rd, 5th, ... row receives the style instead of the correct row 2, 4, 6 etc. It would seem to me that the programmer that designed the underlying code used the index of a zero based index to determine if the row was even or odd. So let me pose this question: Do you think the first row should be considered even or odd?

    Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

    N Offline
    N Offline
    Nish Nishant
    wrote on last edited by
    #7

    In most grids, the first row has a row index of 0. So if you go by the indices, 0,2,4 etc. would be the even rows (which translate to 1st, 3rd, 5th rows from a human perspective). But since the styles are applied by the programmer this should be alright. On the other hand, if the app has an UI option that allows the end-user to set even and odd row styles, then the descriptive text should be swapped so the end user won't be confused. So if the user sets what he thinks is the even row style, internally we set the odd row, and vice-versa.

    Regards, Nish


    Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
    My latest book : C++/CLI in Action / Amazon.com link

    1 Reply Last reply
    0
    • E Ennis Ray Lynch Jr

      Zero based indexes seem to be kicking programmer's A**es even today. I am recently using a software package that allows row styles to be applied for even and odd rows. If you apply an even style the 1st, 3rd, 5th, ... row receives the style instead of the correct row 2, 4, 6 etc. It would seem to me that the programmer that designed the underlying code used the index of a zero based index to determine if the row was even or odd. So let me pose this question: Do you think the first row should be considered even or odd?

      Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

      B Offline
      B Offline
      Brady Kelly
      wrote on last edited by
      #8

      Odd.

      You really gotta try harder to keep up with everyone that's not on the short bus with you. - John Simmons / outlaw programmer.

      1 Reply Last reply
      0
      • R Rama Krishna Vavilala

        Users don't think in terms of zero-th row. It's only programmers who think that there is a row number zero. Usually what I consider row number 0 becomes row 1 for the user. I think that's what Ennis's point was.

        M Offline
        M Offline
        Mustafa Ismail Mustafa
        wrote on last edited by
        #9

        That is different issue. I understood it to mean that Ennis, being the user from the other developer's point, would have to consider the first row what. But you are completely correct, trying to take the user's place would render the first row a "1".

        If the post was helpful, please vote! Current activities: Book: The Gods Themselves by Isaac Asimov Project: Hospital Automation, final stage Learning: Image analysis, LINQ Now and forever, defiant to the end. What is Multiple Sclerosis[^]?

        H 1 Reply Last reply
        0
        • H Henry Minute

          1 is odd. 0, 2, 4, 6 ... eleventyfour are even.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          M Offline
          M Offline
          Mustafa Ismail Mustafa
          wrote on last edited by
          #10

          Henry Minute wrote:

          eleventyfour

          I'd love to know how to render that in digits! :-D

          If the post was helpful, please vote! Current activities: Book: The Gods Themselves by Isaac Asimov Project: Hospital Automation, final stage Learning: Image analysis, LINQ Now and forever, defiant to the end. What is Multiple Sclerosis[^]?

          H D M S 4 Replies Last reply
          0
          • M Mustafa Ismail Mustafa

            Henry Minute wrote:

            eleventyfour

            I'd love to know how to render that in digits! :-D

            If the post was helpful, please vote! Current activities: Book: The Gods Themselves by Isaac Asimov Project: Hospital Automation, final stage Learning: Image analysis, LINQ Now and forever, defiant to the end. What is Multiple Sclerosis[^]?

            H Offline
            H Offline
            Henry Minute
            wrote on last edited by
            #11

            I can't. It is one more than the highest number I know. :-D

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            L 1 Reply Last reply
            0
            • E Ennis Ray Lynch Jr

              Zero based indexes seem to be kicking programmer's A**es even today. I am recently using a software package that allows row styles to be applied for even and odd rows. If you apply an even style the 1st, 3rd, 5th, ... row receives the style instead of the correct row 2, 4, 6 etc. It would seem to me that the programmer that designed the underlying code used the index of a zero based index to determine if the row was even or odd. So let me pose this question: Do you think the first row should be considered even or odd?

              Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

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

              While internally the zeroth row is even, it will likely display as the oneth row, which is odd, and that's all that matters. If you simply have an alternating pattern just to clearly delineate the rows, then it shouldn't matter which rows get which treatment.

              E 1 Reply Last reply
              0
              • R Russell Jones

                Mathematically the first row should have a style all of its own as Zero can't really be classed as either odd or even. It would make sense to style it as even though so that it had the contrasting style to row 1. Of course if you're going to allow the user a choice of what to do then you may end up asking the user what colour you want for the first third and fifth row etc and then set that to the even row style behind the scenes.

                P Offline
                P Offline
                peterchen
                wrote on last edited by
                #13

                Russell Jones wrote:

                as Zero can't really be classed as either odd or even

                How not? I assume the "official" definition is the modulus 2, or somethign equivalent to it.

                Don't attribute to stupidity what can be equally well explained by buerocracy.
                My latest article | Linkify!| FoldWithUs! | sighist

                N 1 Reply Last reply
                0
                • P PIEBALDconsult

                  While internally the zeroth row is even, it will likely display as the oneth row, which is odd, and that's all that matters. If you simply have an alternating pattern just to clearly delineate the rows, then it shouldn't matter which rows get which treatment.

                  E Offline
                  E Offline
                  Ennis Ray Lynch Jr
                  wrote on last edited by
                  #14

                  It just irritated me that I set the even style and the tool applied it to odd rows.

                  Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                  P 1 Reply Last reply
                  0
                  • M Mustafa Ismail Mustafa

                    That is different issue. I understood it to mean that Ennis, being the user from the other developer's point, would have to consider the first row what. But you are completely correct, trying to take the user's place would render the first row a "1".

                    If the post was helpful, please vote! Current activities: Book: The Gods Themselves by Isaac Asimov Project: Hospital Automation, final stage Learning: Image analysis, LINQ Now and forever, defiant to the end. What is Multiple Sclerosis[^]?

                    H Offline
                    H Offline
                    Henry Minute
                    wrote on last edited by
                    #15

                    Please ignore this. I'm using you as a guinea pig.

                    Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                    M 1 Reply Last reply
                    0
                    • H Henry Minute

                      I can't. It is one more than the highest number I know. :-D

                      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #16

                      So show us eleventythree and we will work out how to add one to it... :omg:

                      Luc Pattyn [Forum Guidelines] [My Articles]


                      Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


                      H 1 Reply Last reply
                      0
                      • L Luc Pattyn

                        So show us eleventythree and we will work out how to add one to it... :omg:

                        Luc Pattyn [Forum Guidelines] [My Articles]


                        Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


                        H Offline
                        H Offline
                        Henry Minute
                        wrote on last edited by
                        #17

                        Tomorrow. I'm tired right now.

                        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                        1 Reply Last reply
                        0
                        • H Henry Minute

                          Please ignore this. I'm using you as a guinea pig.

                          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                          M Offline
                          M Offline
                          Mustafa Ismail Mustafa
                          wrote on last edited by
                          #18

                          I understand that I'm hamster like in my behavior, but really, telling me that I'm fat by comparing a hamster to a guinea pig...? :(

                          If the post was helpful, please vote! Current activities: Book: The Gods Themselves by Isaac Asimov Project: Hospital Automation, final stage Learning: Image analysis, LINQ Now and forever, defiant to the end. What is Multiple Sclerosis[^]?

                          H S 2 Replies Last reply
                          0
                          • E Ennis Ray Lynch Jr

                            It just irritated me that I set the even style and the tool applied it to odd rows.

                            Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

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

                            Which odd rows? The displayed odd rows? That would be wrong. Or the rows which internally have odd indices, but which are displayed as even rows? That should be correct. I would think of it as the grid/list/whatever could have a line number (displayed at the left). The line numbers would be one-based. Which lines are getting the even-style?

                            E 1 Reply Last reply
                            0
                            • M Mustafa Ismail Mustafa

                              I understand that I'm hamster like in my behavior, but really, telling me that I'm fat by comparing a hamster to a guinea pig...? :(

                              If the post was helpful, please vote! Current activities: Book: The Gods Themselves by Isaac Asimov Project: Hospital Automation, final stage Learning: Image analysis, LINQ Now and forever, defiant to the end. What is Multiple Sclerosis[^]?

                              H Offline
                              H Offline
                              Henry Minute
                              wrote on last edited by
                              #20

                              No, no, no. I was not saying you were like a guinea pig, only that I was using you like one. I was trying to reproduce a problem that I was having in the programming fora, where after replying to a post, I could no longer select other messages. Needless to say, I could not reproduce it. So you were even useless as a guinea pig! :laugh: :laugh: :laugh:

                              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                              S 1 Reply Last reply
                              0
                              • E Ennis Ray Lynch Jr

                                Zero based indexes seem to be kicking programmer's A**es even today. I am recently using a software package that allows row styles to be applied for even and odd rows. If you apply an even style the 1st, 3rd, 5th, ... row receives the style instead of the correct row 2, 4, 6 etc. It would seem to me that the programmer that designed the underlying code used the index of a zero based index to determine if the row was even or odd. So let me pose this question: Do you think the first row should be considered even or odd?

                                Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                                D Offline
                                D Offline
                                Dan Neely
                                wrote on last edited by
                                #21

                                Userland options should be written to reflect userland expectations. The first row is 1. If the setting is something that can only be changed by editing the registry key HKLM\oh\my\god\worse\than\failure\all\is\not\dead\that\eternal\lies\row_style using zero for the first row isn't an issue in and of itself. You've got other far more serious problems anyway. :rolleyes:

                                It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains. -- Pride and Prejudice and Zombies

                                1 Reply Last reply
                                0
                                • H Henry Minute

                                  1 is odd. 0, 2, 4, 6 ... eleventyfour are even.

                                  Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                                  T Offline
                                  T Offline
                                  Tim Carmichael
                                  wrote on last edited by
                                  #22

                                  My daughter has a DVD that is a pseudo-telling of 'The Lord of the Rings' called 'Lord of the Beans'. Bilbo's equivalent is celebrating his 'twelvetytwoth' birthday. So, in Middle Earth, eleventyfour is perfectly reasonable. But, more to the point, while the indices may start at 0 internally, visually, the first row displayed should be considered odd. Tim

                                  H 1 Reply Last reply
                                  0
                                  • P PIEBALDconsult

                                    Which odd rows? The displayed odd rows? That would be wrong. Or the rows which internally have odd indices, but which are displayed as even rows? That should be correct. I would think of it as the grid/list/whatever could have a line number (displayed at the left). The line numbers would be one-based. Which lines are getting the even-style?

                                    E Offline
                                    E Offline
                                    Ennis Ray Lynch Jr
                                    wrote on last edited by
                                    #23

                                    If I set the even style then the first, third, fifth, etc rows are being styled based on my settings. Which in my opinion is incredibly retarded. It should have been obvious that the item at index zero is the first item. I am starting to believe that modern programmers may not even know why arrays start at 0 anymore. (Ironically it was to make the math easier).

                                    Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                                    P 1 Reply Last reply
                                    0
                                    • T Tim Carmichael

                                      My daughter has a DVD that is a pseudo-telling of 'The Lord of the Rings' called 'Lord of the Beans'. Bilbo's equivalent is celebrating his 'twelvetytwoth' birthday. So, in Middle Earth, eleventyfour is perfectly reasonable. But, more to the point, while the indices may start at 0 internally, visually, the first row displayed should be considered odd. Tim

                                      H Offline
                                      H Offline
                                      Henry Minute
                                      wrote on last edited by
                                      #24

                                      Visually the first row should be considered odd, but mathematically 0 is the first positive even number, so if the first row shown is the zeroeth one it is both odd, as the first row, and even because it it is the zeroeth index. This anomaly is likely to cause a rift in the space-time continuum resulting in a Divide by Something or Other Exception.

                                      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                                      A 1 Reply Last reply
                                      0
                                      • E Ennis Ray Lynch Jr

                                        Zero based indexes seem to be kicking programmer's A**es even today. I am recently using a software package that allows row styles to be applied for even and odd rows. If you apply an even style the 1st, 3rd, 5th, ... row receives the style instead of the correct row 2, 4, 6 etc. It would seem to me that the programmer that designed the underlying code used the index of a zero based index to determine if the row was even or odd. So let me pose this question: Do you think the first row should be considered even or odd?

                                        Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                                        S Offline
                                        S Offline
                                        Single Step Debugger
                                        wrote on last edited by
                                        #25

                                        If we consider the binary number representation it is SO obvious that the zero row is even. The fastest way to check if some number is odd or even is:

                                        bool IsOdd = (RowNumber & 1);

                                        Hence, because zero is 0x00000000 and two is 0x00000010 the both are odd numbers.

                                        The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.

                                        1 Reply Last reply
                                        0
                                        • E Ennis Ray Lynch Jr

                                          If I set the even style then the first, third, fifth, etc rows are being styled based on my settings. Which in my opinion is incredibly retarded. It should have been obvious that the item at index zero is the first item. I am starting to believe that modern programmers may not even know why arrays start at 0 anymore. (Ironically it was to make the math easier).

                                          Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

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

                                          You're right; send them a scathing bug report.

                                          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