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.561.234,561 234,56Available 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.1410.8 with 3 decimals → 10.8005 with 1 decimal → 5.0Formats a number to show a specific number of significant digits.
Examples:
3.14159 with 3 significant figures → 3.14123.456 with 2 significant figures → 1200.0012345 with 2 significant figures → 0.0012Formats a number as currency in the specified currency code.
Examples:
$123.45€123.45¥123Supports 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+30.00123 with 3 decimals → 1.230e-31000000 with 1 decimal → 1.0e+6Returns 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 → 13042 to nearest 5 → 407.8 to nearest 2 → 8Converts 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" → 1000Restricts a number to stay within the specified minimum and maximum values.
Examples:
50 between 0 and 100 → 50150 between 0 and 100 → 100-10 between 0 and 100 → 0It will mostly just go back to the default if something is invalid or doesn't seem to be right.