Click here to Skip to main content
15,920,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make big numbers and use them for arithmetics.
Numbers really..reallly ..reallly big ..(HOW MUCH IS THE LIMIT?)
Multiply two huge numbers and make it even bigger?
I want a plan to do it?
I dont plan to use any extra packages(GMP,BigInteger,LargeInteger, etc.. i already googled them).
What could possibly be the way to do such a thing!!!
Posted

You can check the limits:
http://www.cplusplus.com/reference/climits/[^]

http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html[^]

Both c++ and java depend on the underlying architecture you use. So on an x32 system the register size is 32bits and bigger numbers are often faked by combining 2 registers (eax and edx). Support for even bigger numbers needs to be implemented in special functions because there is no hardware support. This will make them slower. This goes for both java and c++.

Advantage with java is that the jit compiler will compile the program for the actual architecture it runs on. So a c++ program compiled for a 32 bit system will not use 64bit register sizes when running on x64. A java program will use the larger registers because the java runtime will optimize for it automatically.

Good luck!
 
Share this answer
 
The limit is the largest lump of address space your code can access after all the code is loaded. For a 32 bit process you're talking on the order of 2^(2^40).

To actual implement a large number:

- work out how you want to represent the number (fixed point or floating point)
- decide how much precision you want (fixed or variable number of bits)

then code up a class and supporting free functions that implements the data representation and all the arithmetic operations you need. The first two decisions colour what the rest of the class looks like so it's a bit hard to comment on any more implementation issues until you made those decisions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900