Big numbers

Monkey Forums/Monkey Programming/Big numbers

SLotman(Posted 2014) [#1]
Hi guys!

I was playing here a game called "Clicker Heroes" (sorry won't post the link, google it if you want, at your own risk, it's those games that gets very addictive, and not in a good way)

The game is something like "Cookie clicker", and the game has really, really big numbers being used - going up to "vigintillion" O_o

So I was thinking about doing something similar on Monkey, just for kicks - but how would I represent big numbers like that?

The first thing that comes to mind is to actually split numbers into 2 ints, one for the number, other for magnitude - but I'm worried things can get very complicated really soon...

And how would I go about comparisons? Would be possible in Monkey to have a BigNumber Class and then do something like "if big_number_A > big_number_B"?

Does anyone have an advice on this?


ziggy(Posted 2014) [#2]
The best way would be to create a sintrg-based number class that can use numbers of any size number of digits. Calculation is usually slwer, but it could be done like this.


SLotman(Posted 2014) [#3]
I have something working now - still have to implement subtraction, multiplication and comparison, but this link helped me out a lot: http://www.drdobbs.com/a-class-for-representing-large-integers/184403247

Using arrays to store individual numbers is genius! :)