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. General Programming
  3. C / C++ / MFC
  4. assign infinity ?!

assign infinity ?!

Scheduled Pinned Locked Moved C / C++ / MFC
question
9 Posts 8 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.
  • O Offline
    O Offline
    Oriented
    wrote on last edited by
    #1

    I want to know how can i assign infinity to a variable?:omg:

    A D C N J 5 Replies Last reply
    0
    • O Oriented

      I want to know how can i assign infinity to a variable?:omg:

      A Offline
      A Offline
      Alexander M
      wrote on last edited by
      #2

      infinity is not a number, so you can't! you can just use very big values using custom libraries for very big numbers. Don't try it, just do it! ;-)

      1 Reply Last reply
      0
      • O Oriented

        I want to know how can i assign infinity to a variable?:omg:

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Since infinity doesn't exist (i.e., there's always one more number after the biggest number you can think of), how can you assign it to a variable? You can, however, assign a maximum value to integral types like:

        int i = INT_MAX;
        char c = CHAR_MAX;
        unsigned long ul = ULONG_MAX;


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        1 Reply Last reply
        0
        • O Oriented

          I want to know how can i assign infinity to a variable?:omg:

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          It's easy, just use the infinity symbol. If you can't find it, take your keyboard back and demand a replacement. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

          A J 2 Replies Last reply
          0
          • C Christian Graus

            It's easy, just use the infinity symbol. If you can't find it, take your keyboard back and demand a replacement. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

            A Offline
            A Offline
            Alexander M
            wrote on last edited by
            #5

            Brilliant!! :) Don't try it, just do it! ;-)

            1 Reply Last reply
            0
            • O Oriented

              I want to know how can i assign infinity to a variable?:omg:

              N Offline
              N Offline
              Navin
              wrote on last edited by
              #6

              It depends. If you value is a float or double, then it may be possible, take a look at: numeric_limits::infinity() If your variable is an int, long or anything like that, then it is NOT possible to do - no matter what you set the value to, you can add to it and change it. (Although if it goes beyond the maximum value it can hold it will wrap around to a really big negative number!) Now, if you want to know how to create an infinite loop, I've done that many times before... :-D Remember, even if you win the rat race, you're still a rat.

              M 1 Reply Last reply
              0
              • C Christian Graus

                It's easy, just use the infinity symbol. If you can't find it, take your keyboard back and demand a replacement. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                J Offline
                J Offline
                John R Shaw
                wrote on last edited by
                #7

                :laugh::laugh::laugh: Where is the any key? INTP

                1 Reply Last reply
                0
                • N Navin

                  It depends. If you value is a float or double, then it may be possible, take a look at: numeric_limits::infinity() If your variable is an int, long or anything like that, then it is NOT possible to do - no matter what you set the value to, you can add to it and change it. (Although if it goes beyond the maximum value it can hold it will wrap around to a really big negative number!) Now, if you want to know how to create an infinite loop, I've done that many times before... :-D Remember, even if you win the rat race, you're still a rat.

                  M Offline
                  M Offline
                  Maxwell Chen
                  wrote on last edited by
                  #8

                  Navin wrote: if you want to know how to create an infinite loop, I've done that many times before... :-D Maxwell Chen

                  1 Reply Last reply
                  0
                  • O Oriented

                    I want to know how can i assign infinity to a variable?:omg:

                    J Offline
                    J Offline
                    J Eric Vaughan
                    wrote on last edited by
                    #9

                    Wouldn't assigning infinity to a number require an infinite amount of time? If you every figure it out, I'll be glad to test for a small hourly wage ;) The maximum characters for the signature is five hundred. I was wondering how long a five hundred characters message would be, so I decided to make my signature 500 characters long. I'm sure if I had some cool html stuff in my signature, I could eat up five hundred characters, but just typing five hundred characters takes quite some time. The trick I think is finding something to say, but I'm usually a man of few words. So I guess I'll tell you what I've discovered is the secret to life. It

                    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