User Tools

Site Tools


4rpl:commands:asint

This is an old revision of the document!


Index

asint

asint (<-floatval) ->intval

Description

Converts (coerces) an item on the stack to an integer, and pushes it back to the stack.

If used on a float, will truncate any decimal value. i.e. 42.8 asint will return 42. If used on a string, if the string could be numeric (eg. “42”), it will be converted to the corresponding value, if not, the call will return zero.

Examples

Trace (AsInt(42.6))        # 42
Trace (AsInt("42"))        # 42
Trace (AsInt("Forty-two")) # 0

See also:

Index

4rpl/commands/asint.1649840765.txt.gz · Last modified: 2025/02/14 14:56 (external edit)