Algosim documentation: integer

integer

Converts an object to an integer.

Syntax

Description

If X is an integer stored in any object of number type, then integer(X) returns this integer as an integer object.

If X is a vector, matrix, list, set, or structure – in each case containing only a single element which is an integer – then this integer is returned in the form of an integer object.

If X is a string, an attempt is made to parse it as an integer. If successful, the parsed integer is returned.

In all other cases, integer(X) returns an error.

Examples

'((z ≔ 1 + i^2), (n ≔ integer(z))) @ type
complex number
integer
integer(❨❨5, 9, 3, 1❩❩ ⋅ ❨❨7❩, ❨2❩, ❨4❩, ❨0❩❩)
65
integer(❨❨5, 9, 3, 1❩❩ ⋅ ❨❨7❩, ❨2❩, ❨4❩, ❨i❩❩)
failure
Object cannot be represented as a 64-bit integer.
Call stack: integer
integer("1 234 567 890 123 456")
1234567890123456

See also