floor -- r7rs Definition procedure;
Procedure variants:
(((n integer)) -> ((n integer)))
((real-not-inf-not-nan) -> (integer))
real-not-inf-not-nan;integer;((real-inf) -> (real-inf))
((real-nan) -> (real-nan))
scheme:base -- (scheme base);scheme -- (scheme);(floor x) (ceiling x) (truncate x) (round x)These procedures return integers.
The
floorprocedure returns the largest integer not larger thanx. Theceilingprocedure returns the smallest integer not smaller thanx,truncatereturns the integer closest toxwhose absolute value is not larger than the absolute value ofx, androundreturns the closest integer tox, rounding to even whenxis halfway between two integers.Rationale: The
roundprocedure rounds to even for consistency with the default rounding mode specified by the IEEE 754 IEEE floating-point standard.Note: If the argument to one of these procedures is inexact, then the result will also be inexact. If an exact value is needed, the result can be passed to the
exactprocedure. If the argument is infinite or aNaN, then it is returned.(floor -4.3) ===> -5.0 (ceiling -4.3) ===> -4.0 (truncate -4.3) ===> -4.0 (round -4.3) ===> -4.0 (floor 3.5) ===> 3.0 (ceiling 3.5) ===> 4.0 (truncate 3.5) ===> 3.0 (round 3.5) ===> 4.0 ; inexact (round 7/2) ===> 4 ; exact (round 7) ===> 7
The text herein was sourced and adapted as described in the "R7RS attribution of various text snippets" appendix.