By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

How to expand my compiler's ULONG_MAX ?

P: n/a
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.

vg****@verizon.net

August 18, 2004.

Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
victor goban <vg****@verizon.net> 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
kr*******@cybernetik.net
Jul 22 '05 #2

P: n/a
On 19 Aug 2004 01:04:15 GMT in comp.lang.c++, kr*******@cybernetik.net
(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

Jul 22 '05 #3

P: n/a

"victor goban" <vg****@verizon.net> 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.

vg****@verizon.net

August 18, 2004.


With MSVC 6.0 you could also use the
Microsoft specific __int64 type.
Jul 22 '05 #4

P: n/a
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.

vg****@verizon.net

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

Jul 22 '05 #5

P: n/a
On Thu, 19 Aug 2004 08:15:20 +0200, "Friedrich Neurauter"
<fr*****************@eunet.at> wrote:

"victor goban" <vg****@verizon.net> 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.

vg****@verizon.net

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
Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.