Need help with compact notation for my custom numbering system

I have recently started making my own numbering system so that I can go above the cap of 1e+308.

The system itself works great, I can do Multiplication, Division, Addition, and Subtraction with no problems or lag at all. I even got the cap to be 1e+1e+308, which I’d never need even in a game about big numbers.

The problem is being able to display 10000 as 10k. I’ve made a compact notation system before, but this system works a bit different.

Basically, instead of 10000, I have a string “1, 4”. the first number in the string is the first part of e+, and the second is the number of digits, or the second part of e+.

For example, “1, 308” is 1e+308. “1, 1000” is 1e+1000. I even have a system to display numbers as scientific notation. But since its not a single number, my existing system for compact notation won’t work.

I’ve tried a few things, but I ended up getting completely wrong numbers, and I’m not sure where to look.

I could simply set numbers below 1e+308 as compact notation, and use the compact notation converter with a number, and then anything above that use scientific notation, but I’d like to be able to use compact notation through the entire game.

I don’t need an entire script, just an idea on how I’d do this would help a lot.

1 Like

Hmm, I haven’t made a compact notation system before. But If I were to make one right now, I would probably do something like storing notation information in a module script. Something like this:

local data {
    '4' = 'K'
    '5' = 'K'
    '6' = 'K'
    '7' = 'M'
}

and so on. Then I’ll get how many numbers is in the value say for example the player has 154,123$. I would find how many ‘numbers’ is in it. So it has 6. I would get the data in the local data = {} then I would do something like take the 3 numbers infront and do:

local cash = '154123'
if cash.length() == 6 then
    local ReturnedData = data[cash.length()]
    local numberInfront = string.sub(cash, 1, 3) -- this would probably get '154' (i didnt test this script in studio)
    local notatedNumber = numberInfront..ReturnedData -- returned data will be the data that you just go from the local data = {} which will be 'K'
end

(Note: take my reply with a grain of salt. I have never made a compact notation system before)

1 Like