| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
To convert an integer to floating point, use the function float.
float returns
it unchanged.
There are four functions to convert floating point numbers to integers; they differ in how they round. These functions accept integer arguments also, and return such arguments unchanged.
(truncate 1.2)
=> 1
(truncate 1.7)
=> 1
(truncate -1.2)
=> -1
(truncate -1.7)
=> -1
|
If divisor is specified, floor divides number by
divisor and then converts to an integer; this uses the kind of
division operation that corresponds to mod, rounding downward.
An arith-error results if divisor is 0.
(floor 1.2)
=> 1
(floor 1.7)
=> 1
(floor -1.2)
=> -2
(floor -1.7)
=> -2
(floor 5.99 3)
=> 1
|
(ceiling 1.2)
=> 2
(ceiling 1.7)
=> 2
(ceiling -1.2)
=> -1
(ceiling -1.7)
=> -1
|
(round 1.2)
=> 1
(round 1.7)
=> 2
(round -1.2)
=> -1
(round -1.7)
=> -2
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |