Rounding Numbers - CodeAlpaca (1.23K, 45.6M, 789B, etc.)

Hello, CodeAlpaca here!

Ever have the number 345,678 and needed to round it to 345K, or 13,456,543 5 to 13.4M?
Well, you’re in luck!

Just a simple little example that I thought would be useful for people to have. Saw someone trying to make this in the Discord and figured I’d make it because it seemed like they were overcomplicating it.

Some complex-ish expressions, but that doesn’t affect how you use it at all. Just input a number and it does the rest. I should probably add an input to adjust the number of places shown (by default it’s 3. I should add an input so 123456 = 123K, but could be 123.4K if you want instead).

It’s in the “!Bundles” object.

Anyway, that’s all. Just a quick and simple bundle. I completely forgot that I was making this, just ignore the other objects.

Might expand this if I have time to include my other examples + some new ones, not sure yet. This was originally intended to have a ton of practical things that people could use as a quick start, but I just forgot about it for 4 months lol.


Oh and a note, the prefixes “kilo”, “mega”, “giga”, “tera”, “peta”, “exa”, and “zetta” are used. Meaning it’s 100K, 100M, 100B, 100T, etc. You can change the Text List to be Thousand, Million, Billion, etc. if you wanted as well.

11 Likes