Help with turning 1e+21 into 1.00Qn

take a look at this website

doesn’t really help because it wouldn’t work for very big numbers

You can format the number as a string with a certain amount of digits and then work on whatever you want.


it doesn’t seam to work it just print what you put in with spaces at the front

That number was just a random thing I put in. Try typing a massive number which gets turned into scientific annotation and it will return a string of that value only containing 0-9.

again still just doesn’t work
input: 100000000000000000000000000000000000000000000000000000000000000000000000000000
output: 99999999999999998278261272554585856747747644714015897553975120217811154108416

Also a quick note about your code: it seems to be used for GUI so you could put it in a ModuleScript in the client. No need to invoke server just to get the shortened .Text value for some GUI.

That’s because your number is so high it’s hitting the floating point error. The larger the number, the more prominent it becomes. Lua automatically rounds it when printing numbers, otherwise some outputs would be 0.00…01 instead of just 0. In your case, the number is so large that even whole numbers get affected.

r/facepalm right here because this is litteraly the hole point is to to what i am trying to do with numbers this large so why even say this if you know it won’t work for this big numbers

the problem is that there’s a value stored on the server that i need.

Other games deal with this by separating them into different values. Basically, 999,999,999 is a table of {999,999,999}. If the last number increases over 999, increase the previous one by 1.

Although you can practically use anything as the max individual values. You’re basically creating a number of a large base.

1 Like

@berezaa has a module called MoneyLib which has a function to shorten numbers like this.
I also made my own module that can also shorten numbers differently than berezaa’s. It shortens 1e+21 to 1.0Qn+ berezaa’s module would shorten 1e+21 to 1Qn. The link to money lib is here.

this would be useful if it wasn’t because the asset store says no items found when searching for MoneyLib

Guys, you don’t need to do anything you are suggesting :man_facepalming:

You can do operations on numbers of any size, you just can’t store them in a single variable. To solve this just save your number as a string.

To do an addition then on this you would do this:
Variable.Value = tonumber(Variable.Value) + Number

You can then send that string into whatever shortening method you have to display powers of 10 as Qn etc.

I updated my previous post to include my module and berezaa’s module. You can pick which one you like better. My module can only go up to a trillion so far, I can update it for you if you would like.

His issue is hitting a floating point error. It is large enough to make the number vary more than 10k. As for what you said with storing as a single variable, that doesn’t make any sense since the internal value is still a float. Stored float + another float is still a float, and given you are performing operations, the error will be even worse.

Yes, and what I said should fix that. Storing large numbers causes floating point errors, not doing operations on them.

Uh… What? You do realize that a temporary number that you receive from adding 2 floats is a float. If the first float is massive, while the second one is anything, the result will also be massive. The issue is the part which I repeated twice, massive numbers. Addition gives a massive number which has a floating point error.


Not sure what you guys are arguing about with respect to floats. Floats can safely go up to a little higher than a centillion (1 with 303 zeros after it).

Storing numbers up to this size does not cause any errors. The only thing is that if you take a massive number such as 10^200 and try to add 50 to it, that won’t do anything. It won’t do anything because of the way floats represent numbers but I find this to be a non-issue as 50 is such an incomprehensibly smaller number than 10^200 that the difference is negligible.

Miner’s Haven doesn’t do any fancy hacks to store or modify its humongous numbers, and you shouldn’t need to either unless you want to go way higher than a centillion. If you want to do that, you have to define your own “Big number” datatype and define all the basic numerical operations such as addition, multiplication, etc. for that datatype. There is no easy “hack” like the nonsensical tonumber suggestion you can use to squeeze functionality out of floats that isn’t already there.