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.
  • H Henry Minute

    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 Offline
    A Offline
    Anthony Mushrow
    wrote on last edited by
    #27

    Henry Minute wrote:

    but mathematically 0 is the first positive even number

    But you can have negative zero as well!

    My current favourite word is: Delicious!

    -SK Genius

    Game Programming articles start -here[^]-

    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

      M Offline
      M Offline
      Michael Bergman
      wrote on last edited by
      #28

      That's not a math question, it's a UI question. The first row should be determined from the standpoint of the user, so it should be odd, regardless of how it is implemented under the hood. Do you care that Intel handles integers in little endian format while Motorola handles them in big endian format? Not as long as you get the right answer in the end(ian).

      m.bergman

      -- For Bruce Schneier, quanta only have one state : afraid.

      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

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

        What do you mean by first? rows[1] (which is the 1-st row) or rows[0] (there are no rows before this)? I think row[0] should be even, and row[1] odd, because that would fit with the usual modulo math. But I think you should call the row rows[0] the zeroth row, because "first" is ambiguous.

        E 1 Reply Last reply
        0
        • L Lost User

          What do you mean by first? rows[1] (which is the 1-st row) or rows[0] (there are no rows before this)? I think row[0] should be even, and row[1] odd, because that would fit with the usual modulo math. But I think you should call the row rows[0] the zeroth row, because "first" is ambiguous.

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

          Saying the first element in an array is an unambiguous statement. "On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage

          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

          L P 2 Replies Last reply
          0
          • E Ennis Ray Lynch Jr

            Saying the first element in an array is an unambiguous statement. "On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage

            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

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

            Not to me, or to many other people either. How can I know you didn't mean the element with number 1?

            1 Reply 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[^]?

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

              Mustafa Ismail Mustafa wrote:

              Henry Minute wrote: eleventyfour I'd love to know how to render that in digits! Big Grin

              0xB4 :cool:

              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
              • 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
                David Crow
                wrote on last edited by
                #33

                How do you know there is a first row? ;)

                "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                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[^]?

                  S Offline
                  S Offline
                  Steve McLenithan
                  wrote on last edited by
                  #34

                  Mustafa Ismail Mustafa wrote:

                  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...?Frown

                  :laugh: :laugh: :laugh: :laugh: :laugh:

                  // Steve McLenithan

                  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
                    Phil Martin
                    wrote on last edited by
                    #35

                    First row is definitely odd. 0 based indexes should rarely make it to end-user land.

                    1 Reply Last reply
                    0
                    • E Ennis Ray Lynch Jr

                      Saying the first element in an array is an unambiguous statement. "On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage

                      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
                      #36

                      "First" could mean many things in different contexts. As I recall, in Pascal, you can define an array in which the first index is -5 (for example). Which is why I say zeroth and oneth (or negative-fiveth) instead.

                      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.

                        N Offline
                        N Offline
                        Naruki 0
                        wrote on last edited by
                        #37

                        "Zero can't really be classed as either odd or even" This, in fact, is incorrect. Zero is even by all the properties of evenness.

                        Codemonkeys don't do it at all. Too busy coding.

                        R 1 Reply Last reply
                        0
                        • P peterchen

                          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 Offline
                          N Offline
                          Naruki 0
                          wrote on last edited by
                          #38

                          He's mistaken. Wikipedia has a whole page devoted to the topic, with a concise example here[^].

                          Codemonkeys don't do it at all. Too busy coding.

                          R P 2 Replies 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

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

                            Despite being indexed with zero, there really is not a 'zeroth' row. The FIRST row has an index of zero. So, the question is, should the term 'Even Rows' apply to the row or its index? Debate all you want - but I would wager that the majority of implementations, and the majority of technical and non technical people, when presented with a list, would count the first row as one and, therefore, odd. So the implementation you are using is, I'd say, non standard and confusing. Which one is it?

                            ___________________________________________ .\\axxx (That's an 'M')

                            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

                              J Offline
                              J Offline
                              Jorgen Sigvardsson
                              wrote on last edited by
                              #40

                              x % 2 == 0 in general. x % 2 == 1 when dealing with humans. That's my general strategy. I think I have all bases covered!

                              -- Kein Mitleid Für Die Mehrheit

                              1 Reply Last reply
                              0
                              • N Naruki 0

                                "Zero can't really be classed as either odd or even" This, in fact, is incorrect. Zero is even by all the properties of evenness.

                                Codemonkeys don't do it at all. Too busy coding.

                                R Offline
                                R Offline
                                Russell Jones
                                wrote on last edited by
                                #41

                                I think I must have been having a mid afternoon brainfart. Russ

                                1 Reply Last reply
                                0
                                • N Naruki 0

                                  He's mistaken. Wikipedia has a whole page devoted to the topic, with a concise example here[^].

                                  Codemonkeys don't do it at all. Too busy coding.

                                  R Offline
                                  R Offline
                                  Russell Jones
                                  wrote on last edited by
                                  #42

                                  That's a great article, thank you!

                                  N 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

                                    M Offline
                                    M Offline
                                    Momos2302
                                    wrote on last edited by
                                    #43

                                    Hmm Since 0 is not odd nor even from a math point of view, why not solve this problem by assuming a 0-th row can't exist? In fact row 0 is a bit strange if you think about it. So row 1 has the data of your datasource with index 0, and that's no problem in any algorithm. You just can solve it by adding 1 on your data which is indexed 0. Just make a note in the code comments. :laugh:

                                    1 Reply 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[^]?

                                      M Offline
                                      M Offline
                                      Mark_Wallace
                                      wrote on last edited by
                                      #44

                                      110100

                                      I wanna be a eunuchs developer! Pass me a bread knife!

                                      1 Reply Last reply
                                      0
                                      • H Henry Minute

                                        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 Offline
                                        S Offline
                                        sketch2002
                                        wrote on last edited by
                                        #45

                                        <blockquote class="FQ"><div class="FQA">Henry Minute wrote:</div>So you were even useless as a guinea pig!</blockquote> I guess that makes up for calling him fat...

                                        1 Reply 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[^]?

                                          S Offline
                                          S Offline
                                          sketch2002
                                          wrote on last edited by
                                          #46

                                          Mustafa Ismail Mustafa wrote:

                                          Henry Minute wrote: eleventyfour I'd love to know how to render that in digits!

                                          Well... Let's see... if seventy is 70 then eleventy would be 110. If we count in Hexadecimal, "eleventy" would be 6E, so eleventyfour would be 72. And of course we have to use something with a higher base than ten, so I think hexadecimal would be the proper choice given that it is so widely used already, but I would not cry foul if you wanted to use a system with a base of eleven... or eleventy I guess. :-D

                                          H 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