Floats
Factor handbook > The language > Numbers

Prev:Rational numbers
Next:Complex numbers


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

5/4 0.5 + .
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.