Integer Functions
abs
ts
int.abs(): integerReturns the absolute value of an integer. If the integer is negative, it will return the positive value of it.
Input Example:
textwire
{{ (-5).abs() }}Output:
html
5decimal
ts
int.decimal(separator?: string = ".", decimals?: integer = 2): stringEnsures a numeric value has at least the requested number of decimal places. It pads shorter values with zeroes and leaves values that already have enough decimal places unchanged. It does not round or remove extra decimal places.
- Integers are padded with zeroes:
123.decimal()returns string"123.00" - Numeric strings that already have enough decimal places are returned unchanged:
"123.456".decimal()returns string"123.456" - Numeric strings with fewer decimal places are padded:
"123.4".decimal()returns string"123.40" - Strings that are not numbers are returned unchanged
decimals defaults to 2. Negative values are treated as 0.
Arguments:
separator(str) (optional) - The separator to use for the decimal. Default is"."decimals(int) (optional) - How many decimal places to ensure. Default is2. Negative values are treated as0
Input Example:
textwire
{{ 123.decimal() }}
{{ 123.decimal(".", 0) }}
{{ 123.decimal(".", -1) }}Output:
html
123.00
123
123float
ts
int.float(): floatConverts an integer to a float by adding a decimal part of .0 to the number.
Input Example:
textwire
{{ 5.float() }}Output:
html
5.0The value 0 will be converted to 0.0.
len
ts
int.len(): integerReturns the number of digits in an integer. If the integer is negative, it will return the number of digits excluding the - sign.
Input Example:
textwire
{{ 12345.len() }}Output:
html
5str
ts
int.str(): stringConverts an integer to a string and returns it.
Input Example:
textwire
{{ 5.str() }} and {{ (-10).str() }}Output:
html
5 and -10