Coding Question for Anyone Who Knows



In this app called Codea, I would like to make an idle game for mobile. The only problem is, I don't really know how to implement large numbers (like 10^100). If you know how to implement these, that would really help! If you are willi make a code example, the app uses Lua 5.3


I'm sorry!

I can't help you @Valgo.

I don't have the app Codea.

Hope you find the solution!


I have worked on this problem extensively.
Lua can hold big numbers - it just can't really do much with them (It stores them in scientific notation and you can't really apply any operations to them). There are some ways around this, but it depends on the project. What do you aim to accomplish?


I want to use these numbers in an idle game. This means I will need to do the basic operations on them (+, -, *, /, <, =, >). I also need to be able to represent these numbers like this:
1000 = 1K
1000000 = 1M
and so on.


That's okay. I don't NEED to do this, but I want to.


Remember, posts should be hopscotch related ^.^

(Although that does sound super cool!)


Coding related posts are fine as well. :slight_smile:


Okie :D I wasn't sure if that was a stretch for relating it not XD


So, as to your first question, with the new version of Codea, you can represent up to a 10 with 13 zeroes, 10 trillion. You can also add and do operations on it without any troubles. Anything higher than that and you will have to represent it as a string and re implement addition and subtraction and stuff from the ground up, using the way you do it by hand (Adding the ones and carrying, etc)

And as to your second question, Do you just want 1M, 1K, etc. or if it is 1,200,000 do you want it to say 1.2m?


For 1,200,000 I want it to say 1.2M. It will round to 2 (or 3) decimal places.