ratio

When we add, subtract or multiply any two integers, the result is always an integer. However, dividing a numerator by a denominator that is not an integral divisor of the denominator yields a ratio:

1210 11 / .

110

110

100 330 / .

10/33

10/33

14 10 / .

1+2/5

1+2/5

Ratios are printed and can be input literally in the form above. Ratios are always reduced to lowest terms by factoring out the greatest common divisor of the numerator and denominator. A ratio with a denominator of 1 becomes an integer. Division with a denominator of 0 throws an error.

Ratios behave just like any other number -- all numerical operations work as you would expect.

1/2 1/3 + .

5/6

5/6

100 6 / 3 * .

50

50

Ratios can be taken apart:

numerator ( a/b -- a )

denominator ( a/b -- b )

>fraction ( a/b -- a b )

See also

Ratio syntax

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 (2270, heads/master-9a858f779b, Jun 12 2024 16:13:38)