integer-log10 ( x -- n ) (original) (raw)
integer-log10 ( x -- n )
Factor handbook » The language » Numbers » Mathematical functions » Integer functions
Prev: | integer-log2 ( x -- n ) |
---|---|
Next: | integer-sqrt ( x -- n ) |
Inputs
x | a positive rational number |
---|
Outputs
n | an integer |
---|
Word description
Outputs the largest integer n such that 10^n is less than or equal to x.
Errors
Throws an error if x is zero or negative.
Examples
USING: prettyprint math.functions sequences ; { 5 99 100 101 100000000000000000000 100+1/2 1/100 } [ integer-log10 ] map .
{ 0 1 2 2 20 2 -2 }
Definition
USING: math math.functions.private ;
: integer-log10 ( x -- n ) assert-positive (integer-log10) ;
inline