Number Utilities Extension Documentation

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.

Basic Number Formatting

Format Number with Locale

(format number [10000] with locale [English (US) v] :: #59c059)

Formats a number according to the specified locale's conventions. This affects how decimal points, thousands separators, and other formatting elements appear.

Examples:

Available locales include system default and many country-specific options like English (US), Spanish (Spain), Japanese, and more.

Format with Decimal Places

(format [3.14159] with [2] decimal places :: #59c059)

Formats a number with a specific number of decimal places.

Examples:

Format with Significant Figures

(format [3.14159] with [3] significant figures :: #59c059)

Formats a number to show a specific number of significant digits.

Examples:

Currency and Percentage Formatting

Format as Currency

(format [123.45] as currency in [USD v] :: #59c059)

Formats a number as currency in the specified currency code.

Examples:

Supports many currency codes including USD, EUR, GBP, JPY, CNY, and more.

Format as Percentage

(format [0.8547] as percentage with [1] decimals :: #59c059)

Converts a decimal number to a percentage with the specified number of decimal places.

Examples:

Scientific Notation

Convert to Exponential Notation

(convert [1234.5678] to exponential notation with [2] decimals :: #59c059)

Converts a number to scientific notation with the specified number of decimal places.

Examples:

Number Validation

Check if Integer

<is [5] an integer? :: #59c059>

Returns true if the number is an integer (whole number), false otherwise.

Examples:

Check if Finite

<is [42] finite? :: #59c059>

Returns true if the number is finite (not infinity or -infinity), false otherwise.

Examples:

Check if NaN

<is [number] NaN? :: #59c059>

Returns true if the value is NaN (Not a Number), false otherwise.

Examples:

Number Manipulation

Round to Multiple

(round [127] to nearest [10] :: #59c059)

Rounds a number to the nearest multiple of the specified value.

Examples:

Parse Number from Text

(parse number from text [123.45] :: #59c059)

Converts a text string to a number. Returns an error message if the text cannot be converted.

Examples:

Clamp Number

(clamp [50] between [0] and [100] :: #59c059)

Restricts a number to stay within the specified minimum and maximum values.

Examples:

Error Handling

It will mostly just go back to the default if something is invalid or doesn't seem to be right.

Additional Notes