ez.no / exponential / documentation / reference / template operators / formatting / si
$input_value|si( unit [, prefix ] [, decimals ] [, decimal_symbol ] [, thousands_separator ] )
| Name | Type | Description | Required |
|---|---|---|---|
| unit | string | Unit to format input_value to | yes |
| prefix | string | Prefix used to represent input_value | no |
| decimals | integer | Number of decimal digits | no |
| decimal_symbol | string | The symbol to use as decimal separator | no |
| thousands_separator | string | The separator to place inbetween thousands | no |
input_value formated to specified si unit.
Handles unit display of values, most often used for showing sizes of files but can also be used for displaying units on other items such as meters, grams etc.
The operator reads five parameters. The first tells the kind of unit type we're dealing with, for instance: byte, length.
The second determines the behavior of prefixes and is optional.
The third, fourth and fifth determines how to format the number and are option, if not supplied the values will be fetched from the current locale. (Exponential 3.3 or lower does not have these parameters nor this it use locale settings.)
Available units are
You can add custom units by adding to the Base group in units.ini
The prefix is either the name of the size like kilo or one of these
Proper binary prefixes
Commonly used binary prefixes, should not be used if you want to be accurate
Decimal prefixes
All of these values are defined in the INI file units.ini
{1025|si(byte)} {1025|si(byte,binary)} {1025|si(byte,decimal)} {1025|si(byte,none)} {1025|si(byte,auto)} {1025|si(byte,kibi)} {1025|si(byte,kilo)}
If the setting UseSIUnits in site.ini is set to false (default value) then the output will be
1.00 kB 1.00 kB 1.02 kB 1025 B 1.00 kB 1.00 KiB 1.02 kB
If the setting UseSIUnits in site.ini is set to true then the output will be
1.00 KiB 1.00 KiB 1.02 kB 1025 B 1.00 KiB 1.00 KiB 1.02 kB
log in or create a user account to comment.
Comments