Handbook
Glossary
floor ( x -- y )
Factor handbook
»
The language
»
Numbers
»
Mathematical functions
»
Arithmetic functions
Prev:
ceiling ( x -- y )
Next:
truncate ( x -- y )
Vocabulary
math
.
functions
Inputs
x
a
real
Outputs
y
a whole real number
Word description
Outputs the greatest whole number smaller than or equal to
x
.
Notes
The result is not necessarily an integer.
Definition
USING:
kernel
math
;
IN:
math.functions
:
floor
( x -- y )
dup
1
mod
[
dup
0
<
[
-
1
-
]
[
-
]
if
]
unless-zero
;
foldable
flushable