#### Archived

This topic is now archived and is closed to further replies.

# Large numbers

This topic is 5992 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do I make a variable with contains 100-200 numbers (not a array) without making inline asm. An eksamble 20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Sorry for my bad english.

##### Share on other sites
Forgot one thing. I''m useing
VC++ 6.0

##### Share on other sites
Well, this is more of a data structures question than a math question. To tell you the best way, we''d have to know what you are using such large numbers for. Are you mostly multiplying or adding? etc...

You will have to use either a struct or an array to store anything that big. Not necessarily an array entry per digit, though.

##### Share on other sites
The cheap way to do it is to create a class that contains several "long" values, and then you override all the operations of +, -, *, /, etc. Of course, the specifics of how you do it will depend upon your usage of it, but here''s an idea...

  class bigint{ private: // As the value of binary bits are 2^0, 2^1, 2^2... long long1; // value = n^0, where you pick the n long long2; // value = n^1 long long3; // value = n^2 // . // . // . long longI; // value = n^i, where n^(i + 1) > biggest number you hope to make public: bigint(/*...*/); bigint operator+(/*...*/); bigint operator-(/*...*/); bigint operator*(/*...*/); bigint operator/(/*...*/);}

Dragonus
Thought of the Moment
"If success is A, then the equation is A = X + Y + Z, where X is work, Y is play, and Z is keep your mouth shut!"
~ Albert Einstein

##### Share on other sites
AP:
I''m making an encryption engine and the very large number is the key.

Dragonus thanks for your post, but as i''m make A LOT of math it is not a very effective way to do it.

##### Share on other sites
Using asm for direct access to the memory, or dragnuses way are the only two methods that I can think of. Oh, thinking about it a bit more, perhaps you could use a type of floating point method? Maybe you could have a 128bit mantissa, with a 16bit exponent. That would produce extreamly large numbers. The extended precision floating point numbers all ready implimented in the pentium FPU''s ( 80bit )can go up to very large numbers ( gugol upwards ), so you may want to try them.