format-number
Entity | Value |
---|---|
Attribute(s) | style |
Type | value |
Relation | productlist, moreinfo, orderprocess |
Multiple functions can be used within a myshop-calculate extension. One of those functions is format-number(number, format, [decimal-comma]). With this function a number can be displayed using a specific format pattern.
Calculate functions can only be used within a myshop-calculate extension.
Parameters
- number – Required
The number to format, can be an integer or float
- format – Required
The format pattern to use when formatting the given number. The format uses the following pattern:
Character | Meaning | Example |
---|---|---|
0 | Digit | format-number(5.5, ‘#.00’) will show 5.50 |
‘#’ | Digit, zero shows as absent | format-number(5.5, ‘#.##’) will show 5.5 |
. | Decimal point location | format-number(5.5, ‘#.##’) will show 5.5 |
, | Thousands separator location | format-number(10000, ‘##,###.00’) will show 10,000.00 |
% | Displays the number as percentage | format-number(5, ‘#%’) will show 5% |
‘;’ | Pattern separator, for using individual formats for positive and negative numbers | format-number(5, ‘#.00;-#.00’) will show 5.00 format-number(-5, ‘#.00;-#.00’) will show -5.00 |
- decimal-comma – Optional
If you need decimal comma’s instead of points, enter ‘decimal-comma’ as last parameter for this function.
See also
The following extensions may also be interesting if you plan to use this extension:
Post your comment on this topic.