I understand that that's the 32 bit integer limit but I'm making a cookie clicker port, and it's difficult to make a proper clicker when it clocks out at about 4 billion, especially since the first major milestone (ascending) takes 1 trillion cookies. How would I go about making larger integers? Is there a library I can use that adds a new variable type that can go above 2^32-1, and if so how would I implement it? I can't imagine people spending too much time on TI-84 CE cookie clicker lol, so nothing too wild but maybe 2^64 would be good, 2^128 would be perfect but reaaallly stretching it I'd assume. Any help is appreciated!
You can use the uint64_t type.
Can I use a function to render that to the screen (like gfx_PrintUInt) or does that only work with int and unsigned int?
This is absolutely a necro-post, but I think I have some insight which may help you with your latest project. For an incremental game like cookie clicker, it's best to not actually use such large numbers but instead to use something like a float.

The key observation here is that when the player is making trillions of cookies every second, they don't care about single-digit numbers of cookies. Instead, think about their cookie count in something like scientific notation. You store a few significant digits (here called the mantissa) and an exponent of some fixed base. This allows you to scale much, much farther than if you cared about every single cookie, and operations on this number are more or less the same speed regardless of whether the user has 200 cookies or 10^200 cookies. You can read up more on floating point numbers here.
I’ve had good experiences with this library: https://github.com/kokke/tiny-bignum-c
Thank you iPhoenix and Mateo for the suggestions, it's greatly appreciated! I'll try to implement the bn library but worst case scenario I'll try and implement it myself using iPhoenix's suggestion
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement