Skip to content

Integer Functions

abs

ts
int.abs(): integer

Returns 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
5

decimal

ts
int.decimal(separator?: string = ".", decimals?: integer = 2): string

Converts to a string with a decimal part by appending a decimal separator and the number of decimal places. Here are some rules:

  • When the string is not a number, it will return the string as is
  • When the string is already a decimal number, it will return the string as is
  • When you use it on a string, it will return the string as is if it's not a number

Arguments:

  1. separator (str) (optional) - The separator to use for the decimal. Default is "."
  2. decimals (int) (optional) - The number of decimal places to add to the number. Default is 2

Input Example:

textwire
{{ 123.decimal() }}

Output:

html
123.00

float

ts
int.float(): float

Converts an integer to a float by adding a decimal part of .0 to the number

Input Example:

textwire
{{ 5.float() }}

Output:

html
5.0

The value 0 will be converted to 0.0.

len

ts
int.len(): integer

Returns 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
5

str

ts
int.str(): string

Converts an integer to a string and returns it

Input Example:

textwire
{{ 5.str() }} and {{ -10.str() }}

Output:

html
5 and -10