Floats
Up:Numbers, The language, Factor handbook
Prev:Rational numbers
Next:Complex numbers

float
Rational numbers represent exact quantities. On the other hand, a floating point number is an approximation. While rationals can grow to any required precision, floating point numbers are fixed-width, and manipulating them is usually faster than manipulating ratios or bignums (but slower than manipulating fixnums). Floating point numbers are often used to represent irrational numbers, which have no exact representation as a ratio of two integers.

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

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 )
Floating point numbers are represented internally in IEEE 754 double-precision format. This internal representation can be accessed for advanced operations and input/output purposes.
float>bits ( x -- n )
double>bits ( x -- n )
bits>float ( n -- x )
bits>double ( n -- x )

See also
Float syntax