How to expand my compiler's ULONG_MAX ?

V

victor goban

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.

(e-mail address removed)

August 18, 2004.
 
K

Kristofer Pettijohn

victor goban said:
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.
 
D

David Harmon

On 19 Aug 2004 01:04:15 GMT in comp.lang.c++, (e-mail address removed)
(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
 
F

Friedrich Neurauter

victor goban said:
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.

(e-mail address removed)

August 18, 2004.

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

Thomas Matthews

victor said:
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.

(e-mail address removed)

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
 
R

rossum

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top