Handbook
Glossary
ratio
Factor handbook
»
The language
»
Numbers
»
Rational numbers
Next:
numerator ( a/b -- a )
Vocabulary
math
Class description
The class of rational numbers with denominator not equal to 1.
Definition
IN:
math
TUPLE:
ratio
{
numerator
integer
read-only
initial:
0
}
{
denominator
integer
read-only
initial:
0
}
;
Methods
USING:
math
math.functions.private
;
M:
ratio
(integer-log10)
[
(integer-log10)
]
10
(ratio-integer-log)
;
USING:
math
math.functions.private
;
M:
ratio
(integer-log2)
[
(integer-log2)
]
2
(ratio-integer-log)
;
USING:
kernel
math
math.ratios
;
M:
ratio
*
2>fraction
[
*
]
2bi@
/
;
USING:
kernel
math
math.ratios.private
;
M:
ratio
+
scale+d
[
+
]
[
/
]
bi*
;
USING:
kernel
math
math.ratios.private
;
M:
ratio
-
scale+d
[
-
]
[
/
]
bi*
;
USING:
math
math.ratios.private
;
M:
ratio
/
scale
/
;
USING:
math
math.ratios.private
;
M:
ratio
/f
scale
/f
;
USING:
math
math.ratios.private
;
M:
ratio
/i
scale
/i
;
USING:
kernel
math
math.ratios.private
;
M:
ratio
/mod
scale+d
[
/mod
]
[
/
]
bi*
;
USING:
math
math.ratios.private
;
M:
ratio
<
scale
<
;
USING:
math
math.ratios.private
;
M:
ratio
<=
scale
<=
;
USING:
math
math.ratios.private
;
M:
ratio
>
scale
>
;
USING:
math
math.ratios.private
;
M:
ratio
>=
scale
>=
;
USING:
combinators
kernel
math
math.parser
sequences
sequences.private
;
M:
ratio
>base
[
>fraction
[
/mod
]
keep
]
[
[
>base
]
curry
tri@
]
bi*
"/"
glue
over
first-unsafe
{
{
48
[
nip
]
}
{
45
[
append
]
}
[
drop
"+"
glue
]
}
case
;
USING:
math
;
M:
ratio
>bignum
>fraction
/i
>bignum
;
USING:
math
;
M:
ratio
>fixnum
>fraction
/i
>fixnum
;
USING:
math
;
M:
ratio
>float
>fraction
/f
;
USING:
kernel
math
;
M:
ratio
>fraction
[
numerator
]
[
denominator
]
bi
;
inline
USING:
kernel
math
math.functions.private
;
M:
ratio
^n
[
>fraction
]
dip
[
^n
]
curry
bi@
/
;
USING:
kernel
math
math.ratios.private
;
M:
ratio
abs
dup
neg?
[
>fraction
[
neg
]
dip
fraction>
]
when
;
USING:
accessors
math
;
M:
ratio
denominator
denominator>>
;
inline
USING:
compiler.tree.propagation.info
kernel
math
;
M:
ratio
eql?
over
ratio?
[
=
]
[
2drop
f
]
if
;
USING:
kernel
math
math.ratios
;
M:
ratio
equal?
over
ratio?
[
2>fraction
=
[
=
]
[
2drop
f
]
if
]
[
2drop
f
]
if
;
USING:
kernel
math
;
M:
ratio
hashcode*
nip
>fraction
[
hashcode
]
bi@
bitxor
;
USING:
kernel
math
math.ratios.private
;
M:
ratio
mod
scale+d
[
mod
]
[
/
]
bi*
;
USING:
math
;
M:
ratio
neg?
numerator
neg?
;
inline
USING:
math
math.hashcodes
math.hashcodes.private
;
M:
ratio
number-hashcode
>fraction
hash-fraction
;
USING:
kernel
math
math.ratios
;
M:
ratio
number=
2>fraction
number=
[
number=
]
[
2drop
f
]
if
;
USING:
kernel
math
math.text.french
math.text.french.private
;
M:
ratio
number>text
>fraction
[
[
number>text
]
keep
]
[
divisor
]
bi*
swap
abs
1
>
[
pluralize
]
when
space-append
;
USING:
kernel
math
math.text.english
sequences
;
M:
ratio
number>text
>fraction
[
number>text
]
bi@
" divided by "
glue
;
USING:
accessors
math
;
M:
ratio
numerator
numerator>>
;
inline
USING:
kernel
math
math.ratios.private
;
M:
ratio
recip
>fraction
swap
dup
0
<
[
[
neg
]
bi@
]
when
fraction>
;
USING:
math
math.functions
;
M:
ratio
round
[
>=
]
(ratio-round)
;
USING:
math
math.functions
;
M:
ratio
round-to-even
[
(round-to-even?)
]
(ratio-round)
;
USING:
math
math.functions
;
M:
ratio
round-to-odd
[
(round-to-odd?)
]
(ratio-round)
;