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. Brilliant Logic

Brilliant Logic

Scheduled Pinned Locked Moved The Weird and The Wonderful
javascript
17 Posts 15 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
    Roman_wolf
    wrote on last edited by
    #1

    Found this in JavaScript code from one of our designers

    if(a>b && a<=b)
    {
    //do something;
    }
    else
    {
    //do something else;
    }

    :-D

    M B M K M 12 Replies Last reply
    0
    • R Roman_wolf

      Found this in JavaScript code from one of our designers

      if(a>b && a<=b)
      {
      //do something;
      }
      else
      {
      //do something else;
      }

      :-D

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      Well I am sure a designer would read that as... if a is looking at b while on the other side of the bushes b is entering a from behind do something else do something else ALTERNATIVELY The designer knows not how to apply multi lines commenting?

      I may or may not be responsible for my own actions

      1 Reply Last reply
      0
      • R Roman_wolf

        Found this in JavaScript code from one of our designers

        if(a>b && a<=b)
        {
        //do something;
        }
        else
        {
        //do something else;
        }

        :-D

        B Offline
        B Offline
        BillW33
        wrote on last edited by
        #3

        Yes, that is truly an impeccable bit of logic. :doh:

        Just because the code works, it doesn't mean that it is good code.

        1 Reply Last reply
        0
        • R Roman_wolf

          Found this in JavaScript code from one of our designers

          if(a>b && a<=b)
          {
          //do something;
          }
          else
          {
          //do something else;
          }

          :-D

          M Offline
          M Offline
          Manfred Rudolf Bihy
          wrote on last edited by
          #4

          No this is just a more esoteric way of commenting out code. //do something is the stuff being commented out and //do something else is now being done instead. I think this is obvious, isn't it? Cheers! :-D

          1 Reply Last reply
          0
          • R Roman_wolf

            Found this in JavaScript code from one of our designers

            if(a>b && a<=b)
            {
            //do something;
            }
            else
            {
            //do something else;
            }

            :-D

            K Offline
            K Offline
            Kevin Drzycimski
            wrote on last edited by
            #5

            I dont believe your designer wanted it that way, but a comparison to a NAN is always false. I am using a similar NAN-Check if (x != x) ... gets true if x is NAN

            B A 2 Replies Last reply
            0
            • R Roman_wolf

              Found this in JavaScript code from one of our designers

              if(a>b && a<=b)
              {
              //do something;
              }
              else
              {
              //do something else;
              }

              :-D

              M Offline
              M Offline
              Marc A Brown
              wrote on last edited by
              #6

              I think I just threw up a little in my mouth.

              1 Reply Last reply
              0
              • K Kevin Drzycimski

                I dont believe your designer wanted it that way, but a comparison to a NAN is always false. I am using a similar NAN-Check if (x != x) ... gets true if x is NAN

                B Offline
                B Offline
                BobJanova
                wrote on last edited by
                #7

                if(x.isNaN()) (Java) if(double.IsNaN(x)) (C#)

                modified on Wednesday, May 4, 2011 1:53 PM

                A 1 Reply Last reply
                0
                • B BobJanova

                  if(x.isNaN()) (Java) if(double.IsNaN(x)) (C#)

                  modified on Wednesday, May 4, 2011 1:53 PM

                  A Offline
                  A Offline
                  AspDotNetDev
                  wrote on last edited by
                  #8

                  if(isNaN(x)) // JavaScript.

                  [

                  S<T>::f(U) // Out of line.

                  ](http://msdn.microsoft.com/en-us/library/8yk3t00s(v=vs.71).aspx)

                  K 1 Reply Last reply
                  0
                  • K Kevin Drzycimski

                    I dont believe your designer wanted it that way, but a comparison to a NAN is always false. I am using a similar NAN-Check if (x != x) ... gets true if x is NAN

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

                    Then surely one will want to do:

                    if(a > b && a <= b && a != b && !isNaN(a + b)) { /*...*/ }

                    :rolleyes:

                    [

                    S<T>::f(U) // Out of line.

                    ](http://msdn.microsoft.com/en-us/library/8yk3t00s(v=vs.71).aspx)

                    1 Reply Last reply
                    0
                    • R Roman_wolf

                      Found this in JavaScript code from one of our designers

                      if(a>b && a<=b)
                      {
                      //do something;
                      }
                      else
                      {
                      //do something else;
                      }

                      :-D

                      G Offline
                      G Offline
                      gavindon
                      wrote on last edited by
                      #10

                      laugh all you wish, but that's not to far fetched from something some of the tiddlywinks I had classes with would do. Might be why I have a job and they don't but, that's another issue...

                      Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.

                      1 Reply Last reply
                      0
                      • R Roman_wolf

                        Found this in JavaScript code from one of our designers

                        if(a>b && a<=b)
                        {
                        //do something;
                        }
                        else
                        {
                        //do something else;
                        }

                        :-D

                        R Offline
                        R Offline
                        RobCroll
                        wrote on last edited by
                        #11

                        //do something else; like working as an accountant maybe!

                        "You get that on the big jobs."

                        1 Reply Last reply
                        0
                        • R Roman_wolf

                          Found this in JavaScript code from one of our designers

                          if(a>b && a<=b)
                          {
                          //do something;
                          }
                          else
                          {
                          //do something else;
                          }

                          :-D

                          D Offline
                          D Offline
                          Dr Luiji
                          wrote on last edited by
                          #12

                          LOL, that's fantastic. Designers are like women, you can't understand!

                          Dr.Luiji Trust and you'll be trusted. My Blog : The Code Is Art

                          1 Reply Last reply
                          0
                          • R Roman_wolf

                            Found this in JavaScript code from one of our designers

                            if(a>b && a<=b)
                            {
                            //do something;
                            }
                            else
                            {
                            //do something else;
                            }

                            :-D

                            B Offline
                            B Offline
                            Bob1000
                            wrote on last edited by
                            #13

                            This a standard design pattern (SDP) used by Governments, NATO, UN etc in deciding when to take action when civilians are being killed or persecuted "No matter what - don't doing anything" Clearly the designer is very well read and is destined for great things. Note: The design pattern is also used in banking to calculate if the bonus should be a. Very large or b. Just embarrassingly large. Athough it has to be admitted the design pattern is somewhat flawed as no banker has ever been embarrassed!

                            1 Reply Last reply
                            0
                            • R Roman_wolf

                              Found this in JavaScript code from one of our designers

                              if(a>b && a<=b)
                              {
                              //do something;
                              }
                              else
                              {
                              //do something else;
                              }

                              :-D

                              M Offline
                              M Offline
                              Marbry Hardin
                              wrote on last edited by
                              #14

                              Should we assume that it wasn't done intentionally as a temporary bypass?

                              1 Reply Last reply
                              0
                              • R Roman_wolf

                                Found this in JavaScript code from one of our designers

                                if(a>b && a<=b)
                                {
                                //do something;
                                }
                                else
                                {
                                //do something else;
                                }

                                :-D

                                S Offline
                                S Offline
                                Sterling Camden independent consultant
                                wrote on last edited by
                                #15

                                Doesn't apply to Javascript, but in languages that allow separately overloaded operators, this could have a (nefarious) significance.

                                Contains coding, but not narcotic.

                                1 Reply Last reply
                                0
                                • A AspDotNetDev

                                  if(isNaN(x)) // JavaScript.

                                  [

                                  S<T>::f(U) // Out of line.

                                  ](http://msdn.microsoft.com/en-us/library/8yk3t00s(v=vs.71).aspx)

                                  K Offline
                                  K Offline
                                  Kevin Drzycimski
                                  wrote on last edited by
                                  #16

                                  the unequality test is more portable i actually used it in CUDA, afterwards i found out there exists an isnan(x) builtin function now porting to other languages is more easy

                                  1 Reply Last reply
                                  0
                                  • R Roman_wolf

                                    Found this in JavaScript code from one of our designers

                                    if(a>b && a<=b)
                                    {
                                    //do something;
                                    }
                                    else
                                    {
                                    //do something else;
                                    }

                                    :-D

                                    R Offline
                                    R Offline
                                    R Erasmus
                                    wrote on last edited by
                                    #17

                                    and thats why they can't (designers(can't code)). Excuse the pun.

                                    "Program testing can be used to show the presence of bugs, but never to show their absence." << please vote!! >>

                                    modified on Tuesday, May 10, 2011 4:14 AM

                                    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