float

Rational numbers represent exact quantities. On the other hand, a floating point number is an approximate value. While rationals can grow to any required precision, floating point numbers have limited precision, and manipulating them is usually faster than manipulating ratios or bignums.

Introducing a floating point number in a computation forces the result to be expressed in floating point.

5/4 1/2 + .

1+3/4

1+3/4

5/4 0.5 + .

1.75

1.75

Floating point literal syntax is documented in Float syntax.

Integers and rationals can be converted to floats:

>float ( x -- y )

Two real numbers can be divided yielding a float result:

/f ( x y -- z )

Bitwise operations on floats

Floating point comparison operations

The math.floats.env vocabulary provides functionality for controlling floating point exceptions, rounding modes, and denormal behavior.

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.100 x86.64 (2263, heads/master-2c1f38b2d6, Feb 27 2024 12:12:43)