How to expand my compiler's ULONG_MAX ?

Discussion in 'C++' started by victor goban, Aug 19, 2004.

  1. victor goban

    victor goban Guest

    Sorry for beeing ignorant - I'm a beginner.

    I use Microsoft Visual C++, version 6.0.
    A variable of type 'long integer' can store values no more than 2.1 bln.
    However, I'd like to work with a substantially higher numbers, say,
    consisting of 30 - 40 digits (just trying to develope some primitive
    approach to RSA-problem).
    Please advise me if there any methods or programming tricks to resolve
    the problem.

    Thank you. Sincerely,

    Victor Goban.



    August 18, 2004.
    victor goban, Aug 19, 2004
    #1
    1. Advertising

  2. victor goban <> wrote:
    > Sorry for beeing ignorant - I'm a beginner.
    >
    > I use Microsoft Visual C++, version 6.0.
    > A variable of type 'long integer' can store values no more than 2.1 bln.
    > However, I'd like to work with a substantially higher numbers, say,
    > consisting of 30 - 40 digits (just trying to develope some primitive
    > approach to RSA-problem).
    > Please advise me if there any methods or programming tricks to resolve
    > the problem.


    It's a bit off topic since it doesn't deal with the C++ Standard in
    any way.. but the language itself cannot handle numbers larger than
    that as that is all the registers in your CPU can handle. You would
    probably want to consider either writing your own "BigInt" class to
    handle such values, or Google up a BigInt class/library already written.

    --
    Kristofer Pettijohn
    Kristofer Pettijohn, Aug 19, 2004
    #2
    1. Advertising

  3. victor goban

    David Harmon Guest

    On 19 Aug 2004 01:04:15 GMT in comp.lang.c++,
    (Kristofer Pettijohn) wrote,
    >.. but the language itself cannot handle numbers larger than
    >that as that is all the registers in your CPU can handle.


    Nonsense. A conforming C++ compiler must generate code to handle
    numbers larger than the CPU registers, if those registers are smaller
    than 32 bits. Meanwhile, compilers implementing 64bit types on 32bit
    CPUs are becoming common, e.g http://www.digitalmars.com
    David Harmon, Aug 19, 2004
    #3
  4. "victor goban" <> schrieb im Newsbeitrag
    news:kcSUc.21791$iE3.13780@trndny09...
    > Sorry for beeing ignorant - I'm a beginner.
    >
    > I use Microsoft Visual C++, version 6.0.
    > A variable of type 'long integer' can store values no more than 2.1 bln.
    > However, I'd like to work with a substantially higher numbers, say,
    > consisting of 30 - 40 digits (just trying to develope some primitive
    > approach to RSA-problem).
    > Please advise me if there any methods or programming tricks to

    resolve
    > the problem.
    >
    > Thank you. Sincerely,
    >
    > Victor Goban.
    >
    >
    >
    > August 18, 2004.
    >
    >
    >


    With MSVC 6.0 you could also use the
    Microsoft specific __int64 type.
    Friedrich Neurauter, Aug 19, 2004
    #4
  5. victor goban wrote:
    > Sorry for beeing ignorant - I'm a beginner.
    >
    > I use Microsoft Visual C++, version 6.0.
    > A variable of type 'long integer' can store values no more than 2.1 bln.
    > However, I'd like to work with a substantially higher numbers, say,
    > consisting of 30 - 40 digits (just trying to develope some primitive
    > approach to RSA-problem).
    > Please advise me if there any methods or programming tricks to resolve
    > the problem.
    >
    > Thank you. Sincerely,
    >
    > Victor Goban.
    >
    >
    >
    > August 18, 2004.
    >
    >
    >


    Search the web for "big number C++" which will
    result in more than one library for large numbers.

    Two popular libraries are GMP an OpenSSL.
    Here is a link to OpenSSL. Look at the RSA and
    bn(3) functions:
    http://www.openssl.org/docs/crypto/crypto.html


    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.comeaucomputing.com/learn/faq/
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
    Thomas Matthews, Aug 19, 2004
    #5
  6. victor goban

    rossum Guest

    On Thu, 19 Aug 2004 08:15:20 +0200, "Friedrich Neurauter"
    <> wrote:

    >
    >"victor goban" <> schrieb im Newsbeitrag
    >news:kcSUc.21791$iE3.13780@trndny09...
    >> Sorry for beeing ignorant - I'm a beginner.
    >>
    >> I use Microsoft Visual C++, version 6.0.
    >> A variable of type 'long integer' can store values no more than 2.1 bln.
    >> However, I'd like to work with a substantially higher numbers, say,
    >> consisting of 30 - 40 digits (just trying to develope some primitive
    >> approach to RSA-problem).
    >> Please advise me if there any methods or programming tricks to

    >resolve
    >> the problem.
    >>
    >> Thank you. Sincerely,
    >>
    >> Victor Goban.
    >>
    >>
    >>
    >> August 18, 2004.
    >>
    >>
    >>

    >
    >With MSVC 6.0 you could also use the
    >Microsoft specific __int64 type.
    >

    Some other compilers use long long int for 64 bit integers, but again
    this is an extension to the standard and not portable.

    As you are a beginner, it might be worthwhile writing your own big
    integer class as a learning exercise.

    rossum

    --

    The ultimate truth is that there is no Ultimate Truth
    rossum, Aug 19, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yan
    Replies:
    0
    Views:
    1,120
  2. Jack Wright
    Replies:
    5
    Views:
    614
    Shiv Kumar
    Jan 19, 2004
  3. Ram
    Replies:
    0
    Views:
    2,820
  4. victor goban
    Replies:
    1
    Views:
    400
    Ioannis Vranos
    Aug 31, 2004
  5. ccwork

    ULONG_MAX

    ccwork, Apr 20, 2005, in forum: C Programming
    Replies:
    5
    Views:
    779
    Andrey Tarasevich
    Apr 21, 2005
Loading...

Share This Page