coerce.to-integer

coerce.to-integer attempts to coerce an unknown datum to an integer type. It always converts down to the nearest integer.

Function category: Coercion

Syntax

coerce.to-integer(arg1)

Arguments

Description

arg1

Any datum.

Examples

Example 1: Fraction to integer

coerce.to-integer will coerce the value of a fraction to the nearest lower integer value.

coerce.to-integer(3/2) = 1

Example 2: Float to integer

coerce.to-integer will coerce the value of a float to the nearest lower integer value.

coerce.to-integer(2.9) = 2

Example 3: Scientific notation to integer

coerce.to-integer can also coerce numbers in scientific notation.

coerce.to-integer(123.45el) = 1234

Example 4: All other types of data

For all other data, coerce.to-integer will return null.

coerce.to-integer("test") = null

Notes