Arithmetic functions - Factor Documentation (original) (raw)
Arithmetic functions
Factor handbook » The language » Numbers » Mathematical functions
Prev: | Integer functions |
---|---|
Next: | Powers and logarithms |
Computing additive and multiplicative inverses: neg ( x -- -x )
recip ( x -- y )
if-zero ( ..a n quot1: ( ..a -- ..b ) quot2: ( ..a n -- ..b ) -- ..b )
when-zero ( ... n quot: ( ... -- ... x ) -- ... x )
unless-zero ( ... n quot: ( ... n -- ... ) -- ... )
floor ( x -- y )
truncate ( x -- y )
round ( x -- y )
round-to-decimal ( x n -- y )
round-to-step ( x step -- y )
Numbers implement the Linear order protocol, therefore operations such as min and max can be used with numbers.