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. Big int

Big int

Scheduled Pinned Locked Moved C / C++ / MFC
question
19 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.
  • H hackC

    int bignum = 123123425364347456758696679; The compiler says: intger to big for int type (or something like that) How do i make the bignum work? (i'm guessing this is a simple question soooo be gentle :^))

    J Offline
    J Offline
    Joe Woodbury
    wrote on last edited by
    #2

    Try __int64 Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

    D H 2 Replies Last reply
    0
    • H hackC

      int bignum = 123123425364347456758696679; The compiler says: intger to big for int type (or something like that) How do i make the bignum work? (i'm guessing this is a simple question soooo be gentle :^))

      W Offline
      W Offline
      Waldermort
      wrote on last edited by
      #3

      you could also use LARGE_INTEGER

      D 1 Reply Last reply
      0
      • J Joe Woodbury

        Try __int64 Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

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

        Not even close to being large enough. The largest value for __int64 is 263, or 264 if unsigned.


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "We will be known forever by the tracks we leave." - Native American Proverb

        J 1 Reply Last reply
        0
        • J Joe Woodbury

          Try __int64 Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          H Offline
          H Offline
          hackC
          wrote on last edited by
          #5

          _int64 Does that mean a int thats 64 numbers long or is that defined the standard library? nevermind........ 2 to the power or 64. I see. Is LARGE_INTEGER in the standard library too? <--- is that C style programming? "If you try to talk sense to a fool, he'll think your foolish" -- modified at 14:06 Wednesday 26th April, 2006

          J 1 Reply Last reply
          0
          • W Waldermort

            you could also use LARGE_INTEGER

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

            Which also has the same 263 limitation as __int64.


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "We will be known forever by the tracks we leave." - Native American Proverb

            W 1 Reply Last reply
            0
            • D David Crow

              Which also has the same 263 limitation as __int64.


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "We will be known forever by the tracks we leave." - Native American Proverb

              W Offline
              W Offline
              Waldermort
              wrote on last edited by
              #7

              Thanks for pointing that out Mr Crow. Though might I say, it has taken you two replies to say that those of us who are trying to help the OP are wrong. But you have yet to suggest an answer yourself.

              D R 2 Replies Last reply
              0
              • H hackC

                int bignum = 123123425364347456758696679; The compiler says: intger to big for int type (or something like that) How do i make the bignum work? (i'm guessing this is a simple question soooo be gentle :^))

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

                You'll need to use something like the DECIMAL data type, which supports 296. If that is not an option, the only other thing I can think of is to store it as a string. I created a class once that did this, and it had basic math operations (+, -, /, *, !) so you could add, subtract, divide, etc very large numbers.


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "We will be known forever by the tracks we leave." - Native American Proverb

                1 Reply Last reply
                0
                • D David Crow

                  Not even close to being large enough. The largest value for __int64 is 263, or 264 if unsigned.


                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                  "We will be known forever by the tracks we leave." - Native American Proverb

                  J Offline
                  J Offline
                  Joe Woodbury
                  wrote on last edited by
                  #9

                  The pattern of his number indicated to me that he had just semi-randomly typed them to indicate he needed something larger than an int. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                  D 1 Reply Last reply
                  0
                  • H hackC

                    _int64 Does that mean a int thats 64 numbers long or is that defined the standard library? nevermind........ 2 to the power or 64. I see. Is LARGE_INTEGER in the standard library too? <--- is that C style programming? "If you try to talk sense to a fool, he'll think your foolish" -- modified at 14:06 Wednesday 26th April, 2006

                    J Offline
                    J Offline
                    Joe Woodbury
                    wrote on last edited by
                    #10

                    __int64 is 64-bits long. I assumed you had simply typed gibberish indicating you needed a long number. If, however, the number you typed earlier (123123425364347456758696679) actually needs to be stored, __int64 isn't long enough. LARGE_INTEGER is a Win32 thing, but it may be defined by other headers. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                    1 Reply Last reply
                    0
                    • W Waldermort

                      Thanks for pointing that out Mr Crow. Though might I say, it has taken you two replies to say that those of us who are trying to help the OP are wrong. But you have yet to suggest an answer yourself.

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

                      waldermort wrote:

                      But you have yet to suggest an answer yourself.

                      To suggest a way not to do something is in itself an answer. On a similar note, by eliminating all the wrong/incorrect ways of doing something, what we should be left with is the correct way. This was a philosophy used by Thomas Edison.


                      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                      "We will be known forever by the tracks we leave." - Native American Proverb

                      1 Reply Last reply
                      0
                      • J Joe Woodbury

                        The pattern of his number indicated to me that he had just semi-randomly typed them to indicate he needed something larger than an int. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

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

                        As he was not very specific, that's always a possibility.


                        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                        "We will be known forever by the tracks we leave." - Native American Proverb

                        1 Reply Last reply
                        0
                        • H hackC

                          int bignum = 123123425364347456758696679; The compiler says: intger to big for int type (or something like that) How do i make the bignum work? (i'm guessing this is a simple question soooo be gentle :^))

                          J Offline
                          J Offline
                          Joe Woodbury
                          wrote on last edited by
                          #13

                          The bigger question would be "what are you trying to accomplish?" In other words, do you need to simply store the digits or mathematically manipulate them? If the latter, do you really need a number this big? Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                          H 1 Reply Last reply
                          0
                          • J Joe Woodbury

                            The bigger question would be "what are you trying to accomplish?" In other words, do you need to simply store the digits or mathematically manipulate them? If the latter, do you really need a number this big? Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                            H Offline
                            H Offline
                            hackC
                            wrote on last edited by
                            #14

                            The reason is if i were to create a program that reqiures a digit password. But the password would be huge number (harder to figure out). Or is this a bad way to make a password number? Thanks for the answers everybody!!!:-D "If you try to talk sense to a fool, he'll think your foolish" -- modified at 14:33 Wednesday 26th April, 2006

                            J M R 3 Replies Last reply
                            0
                            • H hackC

                              The reason is if i were to create a program that reqiures a digit password. But the password would be huge number (harder to figure out). Or is this a bad way to make a password number? Thanks for the answers everybody!!!:-D "If you try to talk sense to a fool, he'll think your foolish" -- modified at 14:33 Wednesday 26th April, 2006

                              J Offline
                              J Offline
                              Joe Woodbury
                              wrote on last edited by
                              #15

                              My gut feeling is that it's a terrible idea. Beyond that, an __int64 would be sufficient or simply a random string. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                              1 Reply Last reply
                              0
                              • H hackC

                                The reason is if i were to create a program that reqiures a digit password. But the password would be huge number (harder to figure out). Or is this a bad way to make a password number? Thanks for the answers everybody!!!:-D "If you try to talk sense to a fool, he'll think your foolish" -- modified at 14:33 Wednesday 26th April, 2006

                                M Offline
                                M Offline
                                Maximilien
                                wrote on last edited by
                                #16

                                why not "store" it as a string ?


                                Maximilien Lincourt Your Head A Splode - Strong Bad

                                1 Reply Last reply
                                0
                                • H hackC

                                  int bignum = 123123425364347456758696679; The compiler says: intger to big for int type (or something like that) How do i make the bignum work? (i'm guessing this is a simple question soooo be gentle :^))

                                  J Offline
                                  J Offline
                                  Jorgen Sigvardsson
                                  wrote on last edited by
                                  #17

                                  You will need a specialized library for that kind of integer precision. If the LGPL license is not a problem, then go ahead and try gmp[^]. I've used it, and I found it to be quite powerful.

                                  1 Reply Last reply
                                  0
                                  • W Waldermort

                                    Thanks for pointing that out Mr Crow. Though might I say, it has taken you two replies to say that those of us who are trying to help the OP are wrong. But you have yet to suggest an answer yourself.

                                    R Offline
                                    R Offline
                                    Ryan Binns
                                    wrote on last edited by
                                    #18

                                    waldermort wrote:

                                    Though might I say, it has taken you two replies to say that those of us who are trying to help the OP are wrong. But you have yet to suggest an answer yourself.

                                    childish...

                                    Ryan

                                    "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                                    1 Reply Last reply
                                    0
                                    • H hackC

                                      The reason is if i were to create a program that reqiures a digit password. But the password would be huge number (harder to figure out). Or is this a bad way to make a password number? Thanks for the answers everybody!!!:-D "If you try to talk sense to a fool, he'll think your foolish" -- modified at 14:33 Wednesday 26th April, 2006

                                      R Offline
                                      R Offline
                                      Rilhas
                                      wrote on last edited by
                                      #19

                                      If you need a large numeric password then the better way to do it is store it as a string a restrict its contents to characters from '0' to '9'. This password can be arbitrarily long if stored as a string. You would only need it to be represented as an integer if you needed arithmetic or mathematical manipulations. Note that checking if the password is correct does not need mathematics, a simple strcmp() will do the trick. Anyway, if you needed to represent as an integer that fits in 64 bits, then I would sugest _int64 instead of LARGE_INTEGER. The _int64 is a compiler feature, and LARGE_INTEGER is a Windows feature. I would always prefer the compiler feature, for the implementation to be as platform independent as possible. If you need manipulation as an integer and it it larger than 64 bits, then I would sugest you created a class for that. Rilhas

                                      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