• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Large numbers

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

7 replies to this topic

### #1Beerand Alebringer  Members

Posted 23 August 2001 - 01:54 AM

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.

### #2Beerand Alebringer  Members

Posted 23 August 2001 - 01:56 AM

Forgot one thing. I''m useing
VC++ 6.0

### #3Anonymous Poster_Anonymous Poster_*  Guests

Posted 23 August 2001 - 02:06 AM

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.

### #4Dragonus  Members

Posted 23 August 2001 - 02:14 AM

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

### #5Beerand Alebringer  Members

Posted 23 August 2001 - 02:31 AM

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.

### #6python_regious  Members

Posted 23 August 2001 - 03:16 AM

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.

### #7Anonymous Poster_Anonymous Poster_*  Guests

Posted 23 August 2001 - 06:46 AM

### #8Anonymous Poster_Anonymous Poster_*  Guests

Posted 23 August 2001 - 08:14 AM

Public key encryption, right? (RSA /is/ out of patent protection now...)

Dragonus''s suggestion would work fine for a bit reordering scheme such as DES or Triple DES. But then, you''d just search out and download the freely available and cryptographically proven blowfish algo''s source if that''s what you wanted...

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.