🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Large numbers
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.
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.
You will have to use either a struct or an array to store anything that big. Not necessarily an array entry per digit, though.
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...
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
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
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.
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.
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.
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...
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...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement