USING: help math math-internals ; HELP: fixnum f { $description "The class of fixnums, which are fixed-width integers small enough to fit in a machine cell. Because they are not heap-allocated, fixnums do not have object identity. Equality of tagged pointer bit patterns is actually " { $emphasis "value" } " equality for fixnums." } ; HELP: >fixnum "( x -- n )" { $values { "x" "a real number" } { "n" "a fixnum" } } { $description "Converts a real number to a fixnum, with a possible loss of precision and overflow." } ; HELP: bignum f { $description "The class of bignums, which are heap-allocated arbitrary-precision integers." } ; HELP: >bignum "( x -- n )" { $values { "x" "a real number" } { "n" "a bignum" } } { $description "Converts a real number to a bignum, with a possible loss of precision." } ; HELP: integer f { $description "The class of integers, which is a disjoint union of fixnums and bignums." } ; HELP: even? "( n -- ? )" { $values { "n" "an integer" } { "?" "a boolean" } } { $description "Tests if an integer is even." } ; HELP: odd? "( n -- ? )" { $values { "n" "an integer" } { "?" "a boolean" } } { $description "Tests if an integer is odd." } ; HELP: gcd "( x y -- a d )" { $values { "x" "an integer" } { "y" "an integer" } { "a" "an integer" } { "d" "an integer" } } { $description "Computes the positive greatest common divisor " { $snippet "d" } " of " { $snippet "x" } " and " { $snippet "y" } ", and another value " { $snippet "a" } " satisfying:" { $code "a*y = d mod x" } } { $notes "If " { $snippet "d" } " is 1, then " { $snippet "a" } " is the inverse of " { $snippet "y" } " modulo " { $snippet "x" } "." } ; HELP: next-power-of-2 "( m -- n )" { $values { "m" "a non-negative integer" } { "n" "an integer" } } { $description "Outputs the smallest power of 2 greater than " { $snippet "m" } ". The output value is always at least 1." } ; HELP: fraction> "( a b -- a/b )" { $values { "a" "an integer" } { "b" "a positive integer" } { "a/b" "a rational number" } } { $description "Creates a new ratio, or outputs the numerator if the denominator is 1. This word does not reduce the fraction to lowest terms, and should not be called directly; use " { $link / } " instead." } ;