coerce.to-integer

coerce.to-integer attempts to parse unknown data into an integer. It always converts down to the nearest integer.

Function category: Coercion

Syntax

coerce.to-integer(arg1)

Arguments

Description

arg1

Any datum such as a fraction, float or scientific notation. All other types return null.

Examples

Example 1: Fraction to integer

If we have a function that is given a fraction as an argument, this function returns the nearest lower integer value.

# Fraction to integer
coerce.to-integer(3/2)
# Returns 1

Example 2: Float to integer

If we have a function that is given a float number as an argument, this function returns the nearest lower integer value.

# Float to integer
coerce.to-integer(2.9)
# Returns 2

Example 3: Scientific notation to integer

If we have a function that is given a number in scientific notation as an argument, this function returns the nearest lower integer value.

# Scientific notation to integer
coerce.to-integer(123.45el)
# Returns 1234

Example 4: All other types of data

If we have a function that is given data in any other type such as a string, this function returns null.

# All other data types
coerce.to-integer("test")
# Returns null

Notes