factor/library/math/ratio.facts

24 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2006-01-12 00:34:56 -05:00
USING: help math math-internals ;
HELP: ratio f
{ $description "The class of rational numbers with denominator not equal to 1." } ;
HELP: rational f
{ $description "The class of rational numbers, a disjoint union of integers and ratios." } ;
HELP: numerator "( a/b -- a )"
{ $values { "a/b" "a rational number" } { "a" "an integer" } }
{ $description "Outputs the numerator of a rational number. Acts as the identity on integers." } ;
HELP: denominator "( a/b -- b )"
{ $values { "a/b" "a rational number" } { "b" "a positive integer" } }
{ $description "Outputs the denominator of a rational number. Always outputs 1 with integers." } ;
HELP: >fraction "( a/b -- a b )"
{ $values { "a/b" "a rational number" } { "a" "an integer" } { "b" "a positive integer" } }
{ $description "Extracts the numerator and denominator of a rational number." } ;
HELP: 2>fraction "( a/b c/d -- a c b d )"
{ $values { "a/b" "a rational number" } { "a" "an integer" } { "c" "an integer" } { "b" "a positive integer" } { "d" "a positive integer" } }
{ $description "Extracts the numerator and denominator of two rational numbers at once." } ;