[31.1] FormatNumber - A module for formatting numbers

Don’t know why but when I use your module it uses a lot of memory, problem with my use of the module, code or the module itself?

What version are you on? (Yes I’m aware my modules are fragmented)
How much memory (in KiB or MiB) does the module take? I haven’t checked the memory consumption.

I’m on the latest version and it makes memory raise about 1MB per second until the game just breaks.

I like this one, but there is a small bug to fix: if you use FormatPrecision with 0, it results as “0.”
image
An easy fix is to check if the value is 0 and return “0”.

How would you reproduce this bug? I cannot reproduce it on my end.

print(FormatNumber.FormatPrecision(0)) --> 0.00000

What argument(s) did you insert for the function?

FormatNumber.FormatPrecision(0, 1) --> 0.

First one “0” is the value before abbreviation

Here’s my module:

Also, when you try to shorten numbers above 10, it doesn’t show the other digits.
Real value:
image
image


What’s being shown:
image
image

The first bug should be fixed. Thanks for catching it.

FormatPrecision rounds the value by significant digits (significant figures). So in your case, it rounds to 1 significant digits so it doesn’t show any digits other than the 1 digit on the left.

Hey, do you have a list of abbreviations? “K”, “M”, “B”, “T”, e.t.c

I recommend this if you’re looking for English abbreviations up to 10308 (~21024): Cash Suffixes | The Miner's Haven Wikia | Fandom

2 Likes

Where do i put the FormatNumber?

ReplicatedStorage seems to be a popular location to store modules, but you can put it anywhere; it’s your responsibility that you put it in an appropriate location.

I tried but it wont Work :frowning: i tried putting inside the Text but no and in Workspace no still no

Can I ask how would I reproduce the issue and can you be more specific on what’s not working?

Well i scripted my Currency GUI ok its done…and then i Putted the FormatNumber in Replicated Storage or Inside the TextLabel but when i Tested it there are no Comas Showing Up

Why is it not working for me i tried following every thing that said

31.0b1 Update plan

I’m planning to publish version 3.1.0b1 of the module.

It has two APIs, the Main API and the Simple API.
The Main API has no significant changes to the API of the current version (3.0).
The Simple API consists of Format and FormatCompact; and suffixes for FormatCompact can be configurable inside the Simple ModuleScript (multple instances of abbreviations e.g. one has K M B T Qa Qi and the other has k M B T Qd Qn is not supported in this API).
Only comma for grouping and period/full stop for decimal is supported for the Simple API, you should use the Main API if you wish to change this though changing symbols in the Main API is undocumented.
Internally the functions call the Main API under the hood so you get the same result as the Main API.
The reason why I introduced this is because some find the Main API harder to use though I try to make both APIs as easy to use as possible.

This planned update also introduces number skeletons which is another way to configure how you format numbers.
This feature is available on both the Main API and the Simple API .

Use require(--[[Location of FormatNumber]].Main) for the Main API and require(--[[Location of FormatNumber]].Simple) for the Simple API.

Example code (abbreviations in K M B T):

print(SimpleFormatNumber.FormatCompact(123456)) --> 123K 
print(SimpleFormatNumber.FormatCompact(123456, ".#")) --> 123.4K 
print(SimpleFormatNumber.FormatCompacs(12345678, ".## sign-always")) --> +12.34M 
print(SimpleFormatNumber.Format(1234.56)) --> 1,234.56
1 Like

This is beta update as there might be few bugs that I missed, but I’ll most likely be stable soon.

Update 31.0b1

Since the tostring behaviour has changed, the dependency on the DoubleConversion module has been removed.

I’ve also internally modified the structure of the module though there’s no changes to the API that are significant enough.

The new Simple API is introducted for those that just want to format numbers without the hassle of changing settings.

This update introduces number skeletons.

A new option, decimal separator display, has been added.

1 Like

This is awesome, very simple to use, to the point, and efficient. This is perfect for simulator games

Hey, I was wondering if this has been made as a GitHub repo yet or not? I want to add it using Rojo so I don’t have to worry about adding it as an rbxm and for further simplicity.

Very interesting system. Will try this myself once I get back home