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. What is type of foo, if foo != foo?

What is type of foo, if foo != foo?

Scheduled Pinned Locked Moved The Lounge
question
24 Posts 10 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.
  • A Afzaal Ahmad Zeeshan

    Isn't it amazing, how NaN is a number, how a number is a word and how a word is a string. :doh:

    The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

    Sander RosselS Offline
    Sander RosselS Offline
    Sander Rossel
    wrote on last edited by
    #13

    Afzaal Ahmad Zeeshan wrote:

    Isn't it amazing, how NaN is a number

    Yes! Especially since NaN is short for "Not a Number"! X| My whole life is a lie!

    Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

    Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

    Regards, Sander

    A 1 Reply Last reply
    0
    • P Palash Mondal_

      Do you have any reference documentations for it? I want to learn about it more in-depth. Thanks!

      A Offline
      A Offline
      Afzaal Ahmad Zeeshan
      wrote on last edited by
      #14

      Sure, read about Word in computer architecture[^] and the string data type[^]. One thing you should know is that there is no actual string type, it is just an array of characters. :-) Good luck for more in-depths.

      The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

      P 1 Reply Last reply
      0
      • Sander RosselS Sander Rossel

        Afzaal Ahmad Zeeshan wrote:

        Isn't it amazing, how NaN is a number

        Yes! Especially since NaN is short for "Not a Number"! X| My whole life is a lie!

        Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

        Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

        Regards, Sander

        A Offline
        A Offline
        Afzaal Ahmad Zeeshan
        wrote on last edited by
        #15

        Clarified, but how is a number a word (the size of register) and how is a word actually a string (the data type)? :laugh: Plus, short form of your life is a lie (removing the F). :cool:

        The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

        1 Reply Last reply
        0
        • A Afzaal Ahmad Zeeshan

          Sure, read about Word in computer architecture[^] and the string data type[^]. One thing you should know is that there is no actual string type, it is just an array of characters. :-) Good luck for more in-depths.

          The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

          P Offline
          P Offline
          Palash Mondal_
          wrote on last edited by
          #16

          Thanks for it. Have a nice day ahead! :)

          1 Reply Last reply
          0
          • P Palash Mondal_

            Recently had been debugging using the browser console, when I found this answer. Can you guess the type of foo here? Is it a string, function or else?

            J Offline
            J Offline
            Joan M
            wrote on last edited by
            #17

            Any after overloading operators...

            [www.tamautomation.com] | Robots, CNC and PLC machines for grinding and polishing. [YouTube channel]

            1 Reply Last reply
            0
            • M Manfred Rudolf Bihy

              By definition undefined should be unequal to undefined. Is it? Cheers!

              "I had the right to remain silent, but I didn't have the ability!"

              Ron White, Comedian

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

              No, undefined compared with anything (anything includes also again undefined) is "an error" and therefore neither equal nor unequal... it is simply again undefined.

              1 Reply Last reply
              0
              • A Afzaal Ahmad Zeeshan

                Great that you already know the NaN is a number. Now, if you have ever programmed in low-level, you would know that a word is a size given to a data, 1 byte, 2 byte etc. So the size of the register in CPU is a word; pre-defined size, doesn't matter 8-bit 16-bit or what. The size is number, thus, a number is word. :-) Now a word in our language, for example, "Hello", cannot be represented as a word in computer which needs some other type, which is string (array of characters), thus a word is a string. From here comes the metaphor, In programming, a number is a word and a word is a string. :cool:

                The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

                N Offline
                N Offline
                newton saber
                wrote on last edited by
                #19

                Great explanation of how semantics and jargon are sometimes or often at odds with meaning.

                1 Reply Last reply
                0
                • P Palash Mondal_

                  Recently had been debugging using the browser console, when I found this answer. Can you guess the type of foo here? Is it a string, function or else?

                  N Offline
                  N Offline
                  newton saber
                  wrote on last edited by
                  #20

                  spoiler alert -- answer is below Opened Chrome Dev console and ran the following.

                  var x = 'garbage' / 10;

                  x
                  NaN

                  x != x // with coercion
                  true

                  x !== x // even without coercion
                  true

                  typeof(x)
                  "number"

                  P 1 Reply Last reply
                  0
                  • P Palash Mondal_

                    Recently had been debugging using the browser console, when I found this answer. Can you guess the type of foo here? Is it a string, function or else?

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

                    How about int ?

                    private static System.Random randy = new System.Random() ;
                    int foo { get { return ( randy.Next() ) ; } }

                    :-D

                    D 1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      How about int ?

                      private static System.Random randy = new System.Random() ;
                      int foo { get { return ( randy.Next() ) ; } }

                      :-D

                      D Offline
                      D Offline
                      Dennis_E
                      wrote on last edited by
                      #22

                      Or DateTime:

                      DateTime foo { get { return DateTime.Now; } }

                      :-D

                      1 Reply Last reply
                      0
                      • N newton saber

                        spoiler alert -- answer is below Opened Chrome Dev console and ran the following.

                        var x = 'garbage' / 10;

                        x
                        NaN

                        x != x // with coercion
                        true

                        x !== x // even without coercion
                        true

                        typeof(x)
                        "number"

                        P Offline
                        P Offline
                        Palash Mondal_
                        wrote on last edited by
                        #23

                        Awesome :thumbsup:

                        1 Reply Last reply
                        0
                        • P Palash Mondal_

                          Recently had been debugging using the browser console, when I found this answer. Can you guess the type of foo here? Is it a string, function or else?

                          U Offline
                          U Offline
                          User 11783308
                          wrote on last edited by
                          #24

                          NaN

                          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