Index

asfloat

asfloat (<-integer1) ->float1

Description

Converts an item on the stack to a floating point number and pushes it back onto the stack.

This is useful if one needs a floating-point result from operating on two integers. By default, 4RPL may return an integer value after an arithmetic operation on two integers, but a floating-point value might be desirable.

Examples

"1.23" asfloat ->val

Force (coerce) floating point:

4 3 div trace   # yields 1
 
4 asFloat 3 div trace  # yields 1.333..

See also:

Index