diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor index 930d1a21c4..b56c1c105f 100644 --- a/library/bootstrap/boot-stage1.factor +++ b/library/bootstrap/boot-stage1.factor @@ -236,6 +236,7 @@ vectors words ; "/library/math/integer.facts" "/library/math/math.facts" "/library/math/parse-numbers.facts" + "/library/math/pow.facts" "/library/math/random.facts" "/library/math/ratio.facts" "/library/math/trig-hyp.facts" diff --git a/library/math/pow.facts b/library/math/pow.facts new file mode 100644 index 0000000000..a64e43b0ca --- /dev/null +++ b/library/math/pow.facts @@ -0,0 +1,31 @@ +USING: help math ; + +HELP: exp "( x -- y )" +{ $values { "x" "a complex number" } { "y" "a complex number" } } +{ $description "Computes the exponential function." } ; + +HELP: log "( x -- y )" +{ $values { "x" "a complex number" } { "y" "a complex number" } } +{ $description "Computes the natural logarithm function. Outputs negative infinity if " { $snippet "x" } " is 0." } ; + +HELP: sqrt "( x -- y )" +{ $values { "x" "a complex number" } { "y" "a complex number" } } +{ $description "Computes the square root function." } ; + +HELP: ^ "( x y -- z )" +{ $values { "x" "a complex number" } { "y" "a complex number" } { "z" "a complex number" } } +{ $description "Raises " { $snippet "x" } " to the power of " { $snippet "y" } ". If \texttt{y}" { $snippet "y" } " is an integer the answer is computed exactly, otherwise a floating point approximation is used." } +{ $errors "Throws an error if " { $snippet "x" } " and " { $snippet "y" } " are both integer 0." } ; + +HELP: each-bit "( n quot -- )" +{ $values { "n" "an integer" } { "quot" "a quotation with stack effect " { $snippet "( 0/1 -- )" } } } +{ $description "Applies the quotation to each bit of the input, ranging from least significant to most significant." } ; + +HELP: power-of-2? "( n -- ? )" +{ $values { "n" "an integer" } { "?" "a boolean" } } +{ $description "Tests if " { $snippet "n" } " is a power of 2." } ; + +HELP: log2 "( n -- b )" +{ $values { "n" "a positive integer" } { "b" "an integer" } } +{ $description "Computes the largest integer " { $snippet "b" } " such that " { $snippet "2^b" } " is less than " { $snippet "n" } "." } +{ $errors "Throws an error if " { $snippet "n" } " is zero or negative." } ;