]> gitweb.factorcode.org Git - factor.git/blob - basis/math/functions/integer-logs/integer-logs-docs.factor
Switch to https urls
[factor.git] / basis / math / functions / integer-logs / integer-logs-docs.factor
1 ! Copyright (C) 2017 Jon Harper.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel math quotations ;
4 IN: math.functions.integer-logs
5
6 HELP: integer-log10
7 { $values
8     { "x" "a positive rational number" }
9     { "n" integer }
10 }
11 { $description "Outputs the largest integer " { $snippet "n" } " such that " { $snippet "10^n" } " is less than or equal to " { $snippet "x" } "." }
12 { $errors "Throws an error if " { $snippet "x" } " is zero or negative." } ;
13
14 HELP: integer-log2
15 { $values
16     { "x" "a positive rational number" }
17     { "n" integer }
18 }
19 { $description "Outputs the largest integer " { $snippet "n" } " such that " { $snippet "2^n" } " is less than or equal to " { $snippet "x" } "." }
20 { $errors "Throws an error if " { $snippet "x" } " is zero or negative." } ;
21
22 ARTICLE: "integer-logs" "Integer logarithms"
23 "The " { $vocab-link "math.functions.integer-logs" } " vocabulary provides exact integer logarithms for all rational numbers:"
24 { $subsections integer-log2 integer-log10 }
25 { $examples
26     { $example
27         "USING: prettyprint math.functions.integer-logs sequences ;"
28         "{"
29         "     5 99 100 101 100000000000000000000"
30         "     100+1/2 1/100"
31         "} [ integer-log10 ] map ."
32         "{ 0 1 2 2 20 2 -2 }"
33     }
34 } ;
35
36 ABOUT: "integer-logs"