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. Other Discussions
  3. The Weird and The Wonderful
  4. Ha ha

Ha ha

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
14 Posts 10 Posters 16 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.
  • S ScottM1

    if ((a == a) || (a != a))
    {
    MessageBox.Show("That is correct, well done!!!");
    }

    :laugh: WTF?

    There are 10 types of people in the world, those who understand binary and those who dont.

    K Offline
    K Offline
    KarstenK
    wrote on last edited by
    #4

    Better would be if ((a == a) && !(a != a)) { MessageBox.Show("That is correct, well done!!!"); } to make it clear :-O

    Greetings from Germany

    1 Reply Last reply
    0
    • S ScottM1

      if ((a == a) || (a != a))
      {
      MessageBox.Show("That is correct, well done!!!");
      }

      :laugh: WTF?

      There are 10 types of people in the world, those who understand binary and those who dont.

      D Offline
      D Offline
      dighn
      wrote on last edited by
      #5

      There's like two levels of redundancy in there. It's sorta cool in a demented way.

      S 1 Reply Last reply
      0
      • D dighn

        There's like two levels of redundancy in there. It's sorta cool in a demented way.

        S Offline
        S Offline
        Sameer Alibhai
        wrote on last edited by
        #6

        The ones I find really silly and I see quite often in our codeset are like boolIsFive = val = "5" ? true : false Correction: boolIsFive = val == "5" ? true : false; -- modified at 8:14 Wednesday 6th June, 2007

        Author, SharpDeveloper.NET

        R J 2 Replies Last reply
        0
        • G Giorgi Dalakishvili

          :laugh: Strange that the author of the code didn't write this: if ((a == a)) { MessageBox.Show("That is correct, well done!!!"); }

          my articles

          D Offline
          D Offline
          Daniel Grunwald
          wrote on last edited by
          #7

          "if (a == a)" actually has a meaning if a is of type double: double.NaN isn't equal to itself. Try it.

          D 1 Reply Last reply
          0
          • D Daniel Grunwald

            "if (a == a)" actually has a meaning if a is of type double: double.NaN isn't equal to itself. Try it.

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

            maybe, but if that's the only case is there a way to test if a double is NaN directly? That'd be safer than hoping a clueless maintainance programmer wouldn't delete the explanatory comment as unneeded clutter on one update and then remove the if (a == a) test as useless on the next pass.

            -- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer

            D 1 Reply Last reply
            0
            • D Dan Neely

              maybe, but if that's the only case is there a way to test if a double is NaN directly? That'd be safer than hoping a clueless maintainance programmer wouldn't delete the explanatory comment as unneeded clutter on one update and then remove the if (a == a) test as useless on the next pass.

              -- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer

              D Offline
              D Offline
              Daniel Grunwald
              wrote on last edited by
              #9

              That's why System.Double contains the method public static bool IsNaN(double d) { return d != d; }

              1 Reply Last reply
              0
              • S Sameer Alibhai

                The ones I find really silly and I see quite often in our codeset are like boolIsFive = val = "5" ? true : false Correction: boolIsFive = val == "5" ? true : false; -- modified at 8:14 Wednesday 6th June, 2007

                Author, SharpDeveloper.NET

                R Offline
                R Offline
                Rage
                wrote on last edited by
                #10

                Sameer Alibhai wrote:

                I see quite often in our codeset

                :~

                Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]

                S 1 Reply Last reply
                0
                • S Sameer Alibhai

                  The ones I find really silly and I see quite often in our codeset are like boolIsFive = val = "5" ? true : false Correction: boolIsFive = val == "5" ? true : false; -- modified at 8:14 Wednesday 6th June, 2007

                  Author, SharpDeveloper.NET

                  J Offline
                  J Offline
                  jhwurmbach
                  wrote on last edited by
                  #11

                  Sameer Alibhai wrote:

                  bool IsFive = val = "5" ? true : false

                  You know the intern that produces this? You could tell him the secret hack

                  bool IsFive = (val == "5");

                  I presume the assignment of "5" was a typo?


                  Failure is not an option - it's built right in.

                  S 1 Reply Last reply
                  0
                  • R Rage

                    Sameer Alibhai wrote:

                    I see quite often in our codeset

                    :~

                    Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]

                    S Offline
                    S Offline
                    Sameer Alibhai
                    wrote on last edited by
                    #12

                    Point well taken.

                    Author, SharpDeveloper.NET

                    1 Reply Last reply
                    0
                    • J jhwurmbach

                      Sameer Alibhai wrote:

                      bool IsFive = val = "5" ? true : false

                      You know the intern that produces this? You could tell him the secret hack

                      bool IsFive = (val == "5");

                      I presume the assignment of "5" was a typo?


                      Failure is not an option - it's built right in.

                      S Offline
                      S Offline
                      Sameer Alibhai
                      wrote on last edited by
                      #13

                      That is correct, thank you. Here's the VB.net version btnSubmit.Visible = IIf(_mode = "Read", false, true)

                      Author, SharpDeveloper.NET

                      1 Reply Last reply
                      0
                      • S ScottM1

                        if ((a == a) || (a != a))
                        {
                        MessageBox.Show("That is correct, well done!!!");
                        }

                        :laugh: WTF?

                        There are 10 types of people in the world, those who understand binary and those who dont.

                        S Offline
                        S Offline
                        Sylvester george
                        wrote on last edited by
                        #14

                        When it will not execute? Answer is a = 10 and a = 11

                        Regards, Sylvester G sylvester_g_m@yahoo.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