Factor Documentation
|
Home
|
Glossary
|
Search
factorcode.org
Arithmetic functions
Factor documentation
>
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 )
Complex conjugation:
conjugate
( z -- z* )
Tests:
zero?
( x -- ? )
between?
( x y z -- ? )
Control flow:
if-zero
( ..a n quot1: ( ..a -- ..b ) quot2: ( ..a n -- ..b ) -- ..b )
when-zero
( ..a n quot: ( ..a -- ..b ) -- ..b )
unless-zero
( ..a n quot: ( ..a -- ..b ) -- ..b )
Sign:
sgn
( x -- n )
Rounding:
ceiling
( x -- y )
floor
( x -- y )
truncate
( x -- y )
round
( x -- y )
Inexact comparison:
~
( x y epsilon -- ? )
Numbers implement the
Linear order protocol
, therefore operations such as
min
and
max
can be used with numbers.