The Number Utilities extension adds useful number formatting and manipulation capabilities to your projects. This extension provides blocks for formatting numbers in different locales, working with decimals, currencies, and performing various number checks and conversions.
Formats a number according to the specified locale's conventions. This affects how decimal points, thousands separators, and other formatting elements appear.
Examples:
1,234.56
1.234,56
1 234,56
Available locales include system default and many country-specific options like English (US), Spanish (Spain), Japanese, and more.
Formats a number with a specific number of decimal places.
Examples:
3.14159
with 2 decimals → 3.14
10.8
with 3 decimals → 10.800
5
with 1 decimal → 5.0
Formats a number to show a specific number of significant digits.
Examples:
3.14159
with 3 significant figures → 3.14
123.456
with 2 significant figures → 120
0.0012345
with 2 significant figures → 0.0012
Formats a number as currency in the specified currency code.
Examples:
$123.45
€123.45
¥123
Supports many currency codes including USD, EUR, GBP, JPY, CNY, and more.
Converts a decimal number to a percentage with the specified number of decimal places.
Examples:
0.8547
with 1 decimal → 85.5%
0.333
with 2 decimals → 33.30%
1.5
with 0 decimals → 150%
Converts a number to scientific notation with the specified number of decimal places.
Examples:
1234.5678
with 2 decimals → 1.23e+3
0.00123
with 3 decimals → 1.230e-3
1000000
with 1 decimal → 1.0e+6
Returns true if the number is an integer (whole number), false otherwise.
Examples:
5
→ true5.5
→ false0
→ trueReturns true if the number is finite (not infinity or -infinity), false otherwise.
Examples:
42
→ trueInfinity
→ false-Infinity
→ falseReturns true if the value is NaN (Not a Number), false otherwise.
Examples:
NaN
→ true42
→ false"hello"
→ true (when converted to number)Rounds a number to the nearest multiple of the specified value.
Examples:
127
to nearest 10
→ 130
42
to nearest 5
→ 40
7.8
to nearest 2
→ 8
Converts a text string to a number. Returns an error message if the text cannot be converted.
Examples:
"123.45"
→ 123.45
"abc"
→ Error: Invalid number
"1e3"
→ 1000
Restricts a number to stay within the specified minimum and maximum values.
Examples:
50
between 0
and 100
→ 50
150
between 0
and 100
→ 100
-10
between 0
and 100
→ 0
It will mostly just go back to the default if something is invalid or doesn't seem to be right.