Jump to content
  • Advertisement

Archived

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

Yanroy

More efficient number storage?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.






Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!