More efficient number storage?

Started by
12 comments, last by Yanroy 23 years, 11 months ago
quote:Original post by Eric

Actually, Milo, I heard kiren_j''s compression algorithm is based on this system...



I thought he was inputting these number sequences obtained from here as a non-dynamic quadrafoil fluidic with a disengaged hypnotic stress level test???

Hmmm, maybe I need coffee.






Advertisement
I see my mistake.... dang it! I thought I had something that might actually be useful for a while... You can still use it to store huge numbers though.

--------------------


You are not a real programmer until you end all your sentences with semicolons;

Yanroy@usa.com

Visit the ROAD Programming Website

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

Yanroy...I''m really sorry to burst your bubble, but you don''t gain anything by using this class over a long (signed or unsigned). In fact, you lose efficiency. Sorry bud. Keep working, though.
Sorry to say, as is, you gain nothing with this code. Each byte (unsigned char) has one of 256 possible values. You have four bytes, therefore there are a total of 256^4 possible values. 256^4 == (2^8)^4 == 2^32. You have just recreated the 32-bit integer.

However, if you extend your array to more than four bytes (say 8 bytes, 16 bytes, or even 256 bytes or more!), then you can do what you''re looking for. For example, let''s say you used an array of 16 bytes. Total combos == 256^16 == (2^8)^16 == 2^128. You can now store (unsigned) integers from 0 to (2^128)-1.

Also, if you extend your arrays, your GetValue() will no longer work. Aside from the fact that you''ll probably lose a good chunk of information converting to doubles. You are better off overloading operators on BigNum to do your calculations.

---- --- -- -
Blue programmer needs food badly. Blue programmer is about to die!

This topic is closed to new replies.

Advertisement