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. Managed C++/CLI
  4. C++/CLI Convert long Strings to Int

C++/CLI Convert long Strings to Int

Scheduled Pinned Locked Moved Managed C++/CLI
c++question
9 Posts 4 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.
  • J Offline
    J Offline
    J_E_D_I
    wrote on last edited by
    #1

    int BigNumber = Convert::ToInt64(BigString);

    I am trying to create an Int (BigNumber) from a very long String (BigString, which is made up of let's say ~25 characters). Should I use ToInt64 or ToInt32? What are the character limits of the two? What's better? Thank you!

    L M 2 Replies Last reply
    0
    • J J_E_D_I

      int BigNumber = Convert::ToInt64(BigString);

      I am trying to create an Int (BigNumber) from a very long String (BigString, which is made up of let's say ~25 characters). Should I use ToInt64 or ToInt32? What are the character limits of the two? What's better? Thank you!

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, you probably know what the largest value is a 32-bit int can hold; if not look at Int32.MaxValue. a 64-bit int can hold about the square of that. Neither will reach a 25-digit string representation assuming decimal and no leading zeroes. Also it does not make sense to call ToInt64 and store the result in an int; the compiler will object to that. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


      1 Reply Last reply
      0
      • J J_E_D_I

        int BigNumber = Convert::ToInt64(BigString);

        I am trying to create an Int (BigNumber) from a very long String (BigString, which is made up of let's say ~25 characters). Should I use ToInt64 or ToInt32? What are the character limits of the two? What's better? Thank you!

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Neither Int32 or Int64 are going to hold a ~25 digit number. 2^32 = 4294967296 2^64 = 18446744073709551616

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        L 1 Reply Last reply
        0
        • M Mark Salsbery

          Neither Int32 or Int64 are going to hold a ~25 digit number. 2^32 = 4294967296 2^64 = 18446744073709551616

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Mark Salsbery wrote:

          2^32 = 4294967296 2^64 = 18446744073709551616

          Actually for signed integers the maximum values are one less than half of those numbers. BTW: you should use thousand separator characters to keep such numbers somewhat readable... :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


          M 1 Reply Last reply
          0
          • L Luc Pattyn

            Mark Salsbery wrote:

            2^32 = 4294967296 2^64 = 18446744073709551616

            Actually for signed integers the maximum values are one less than half of those numbers. BTW: you should use thousand separator characters to keep such numbers somewhat readable... :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            Yeah.....um....thanks for the tips Luc :rolleyes: ;P

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            L L 2 Replies Last reply
            0
            • M Mark Salsbery

              Yeah.....um....thanks for the tips Luc :rolleyes: ;P

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              You err are welcome. :-D

              Luc Pattyn [Forum Guidelines] [My Articles]


              - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


              1 Reply Last reply
              0
              • M Mark Salsbery

                Yeah.....um....thanks for the tips Luc :rolleyes: ;P

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                Mark Salsbery wrote:

                thanks for the tips

                Here's another: If you give a man a fish he'll stink up the whole village, but give him a fishing rod, see where I'm going with this? Give him a fishing rod and he'll poke yer eye out.

                M L 2 Replies Last reply
                0
                • L led mike

                  Mark Salsbery wrote:

                  thanks for the tips

                  Here's another: If you give a man a fish he'll stink up the whole village, but give him a fishing rod, see where I'm going with this? Give him a fishing rod and he'll poke yer eye out.

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  :laugh: :jig:

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  1 Reply Last reply
                  0
                  • L led mike

                    Mark Salsbery wrote:

                    thanks for the tips

                    Here's another: If you give a man a fish he'll stink up the whole village, but give him a fishing rod, see where I'm going with this? Give him a fishing rod and he'll poke yer eye out.

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    One should always wear safety glasses when using hazardous equipment, such as Windows PCs. :laugh: :laugh:

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


                    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