Repository navigation
BLL Number
Method reference · date · time · Examples
number turns a number into localized text. Use it to display decimals,
percentages, prices or measurements. Calculate first, then format the result.
For example, in a supported text field:
Price: {[ number(12.5, "currency", "EUR", "code", 2, "en-US") ]}
In an expression-only card, omit {[ ]}. Formatted text can contain
locale-specific separators, symbols and spaces; do not assume it is suitable
for further arithmetic.
The community guide describes these forms:
number(value, decimals?, locale?)
number(value, style?, decimals?, locale?)
number(value, style?, styleOption1?, decimals?, locale?)
number(value, style?, styleOption1?, styleOption2?, locale?)
number(value, style?, styleOption1?, styleOption2?, decimals?, locale?)
Supply a number, not a string containing a localized number. The default
style is decimal; locale defaults to BLL's configured locale. Specified
decimals sets both minimum and maximum fraction digits. The 4.2.3 source
selects overloads based on argument types: combinations with omitted options,
null, decimals and locale can behave differently from what you expect.
Prefer the examples below and test the actual output. The Format number
Flow action exposes these options separately.
| Expression | Example output | Use |
|---|---|---|
number(1234.567, 2, "en-US") |
1,234.57 |
Two decimals in US English. |
number(1234.567, 2, "nl-NL") |
1.234,57 |
The same value using Dutch separators. |
number(9, 2, "en-US") |
9.00 |
Pad to two decimals. |
number(3.14159, 3, "en-US") |
3.142 |
Round for display. |
number(1234567, "decimal", "compact_short") |
Locale-dependent | Compact notation. |
number(1234.5, "decimal", "scientific") |
Locale-dependent | Scientific notation. |
Decimal notation options include standard, scientific, engineering,
compact_short and compact_long. The community guide also mentions
noGrouping as the second style option. In the 4.2.3 expression implementation
the string "noGrouping" is not recognized in the same way as the Flow
card's option object; do not assume it suppresses separators in an expression.
| Expression | Example output | Use |
|---|---|---|
number(0.125, "percent", 1, "en-US") |
12.5% |
Display a fraction as a percentage. |
number(1.45, "percent") |
Locale-dependent, representing 145% | A value of 1 means 100%. |
number(0.145, "percent", null, "nl") |
Locale-dependent | Dutch percentage formatting from app settings. |
The percent style has no currency or unit options. If your source value is
already 12.5 for 12.5%, divide by 100 before formatting.
These example results use locale en-US:
| Expression | Example result (en-US) |
Use |
|---|---|---|
number(12.5, "currency", "EUR", "code", 2, "en-US") |
EUR 12.50 |
Euro amount using a currency code and two decimals. |
number(12.5, "currency", "USD", "symbol", 2, "en-US") |
$12.50 |
US dollar amount with a symbol. |
number(1.45, "currency", "EUR", "name", "en-US") |
1.45 euros |
Localized currency name. |
number(1.45, "currency", "EUR", null, "en-US") |
€1.45 |
Euro amount using the locale's default currency display. |
Use a valid currency code such as EUR or USD. Display options include
symbol, narrowSymbol, code and name. Symbols and spacing are
locale-dependent. Formatting does not convert exchange rates.
These example results use locale en-US:
| Expression | Example result (en-US) |
Use |
|---|---|---|
number(21, "unit", "celsius", "long", 1, "en-US") |
21.0 degrees Celsius |
Temperature with a long unit label. |
number(1.45, "unit", "kilometer", "narrow", "en-US") |
1.45km |
Distance with a narrow unit label. |
number(5, "unit", "liter", "short", 0, "en-US") |
5 L |
Volume with a short unit label. |
number(30, "unit", "minute", "long", 0, "en-US") |
30 minutes |
Duration expressed as a number of minutes. |
The unit is a label, not a unit conversion. Options include long, short
and narrow; the Format number card's 4.2.3 unit picker offers the
following identifiers:
- Area:
acre,hectare - Digital information:
bit,byte,gigabit,gigabyte,kilobit,kilobyte,megabit,megabyte,petabyte,terabit,terabyte - Length:
centimeter,foot,inch,kilometer,meter,mile,mile-scandinavian,millimeter,yard - Volume:
fluid-ounce,gallon,liter,milliliter - Mass:
gram,kilogram,ounce,pound,stone - Temperature:
celsius,fahrenheit - Time:
day,hour,millisecond,minute,month,second,week,year - Other:
degree,percent
The locale/runtime determines the displayed name and whether a combination is valid. Check the autocomplete choices in your installed version. For a duration broken down into hours, minutes and seconds, use time.
In the HTTP formatting discussion,
the recipient requires a trailing zero, for example 24.50. Store or pass
formatted text: a number variable represents the value, not its visual
decimal padding.
| Bare expression | Text result | Use |
|---|---|---|
number(24.5, 2, "en-US") |
24.50 |
Localized display for a small value. |
(24.5).toFixed(2) |
24.50 |
Fixed decimals with a dot and no grouping. |
(23397.244).toFixed(3) |
23397.244 |
Machine-oriented text without thousands separators. |
The toFixed expressions are JavaScript adaptations for endpoints requiring
a fixed, nonlocalized representation. They return text and use JavaScript
floating-point rounding; they are not arbitrary-precision financial arithmetic.
If you use number, remember that larger values can acquire grouping
separators.
For the spreadsheet case
requesting 23397,244 instead of 23.397,244, use Format number with
decimal style, three decimals, the appropriate Dutch locale, and
No Grouping as the second style option. Verify the receiving spreadsheet's
locale too. The expression overload caveat above still applies; do not
assume passing "noGrouping" to number(...) works identically.
See the HTTP workflow for passing the formatted result onward.
Support development - If Better Logic Library is useful to you, you can support its
continued development through GitHub Sponsors,
Patreon,
PayPal, or
bunq.
Thank you!