Numbers
4.1 The Numeric Tower
Machine-word integers (fast) (expt 2 100) Arbitrary precision (automatic) single-float / double-float 3.14, 3.14d0, 1.0e10
Floats (3.14 reads as single-float by default) Integer literals in other bases #b1010, #o755, #xFF, #36rLISP Binary, octal, hex, radix
Floating-point reading: set *read-default-float-format* to 'double-float if you want 3.14 to read as a double.
(+ 1 2 3) ; 6
(/ 1 3) ; 1/3: exact ratio
(/ 6 3) ; 2
(/ 1.0 3) ; 0.33333334 (single-float)
(/ 1d0 3) ; 0.3333333333333333d0
(float 1/3 1d0) ; 0.3333333333333333d0
(expt 2 100) ; 1267650600228229401496703205376
(sqrt 16) ; 4.0
(sqrt -1) ; #C(0.0 1.0)
(isqrt 17) ; 4 (integer square root)
(abs -5) (max 1 5 3) (min 1 5 3)
(1+ 5) (1- 5) ; 6 4
(mod -7 3) ; 2 (sign of the divisor)
(rem -7 3) ; -1 (sign of the dividend)
(floor 7 2) ; 3, 1 (two values: quotient and remainder)
(truncate -7 2) ; -3, -1
(round 2.5) ; 2, 0.5 (rounds to even)
(ceiling 7 2) ; 4, -1
(gcd 12 18) (lcm 4 6) ; 6 12
(numerator 2/3) (denominator 2/3) ; 2 3
(rational 0.5) ; 1/2
(evenp 4) (oddp 3) (zerop 0) (plusp 3) (minusp -1)
(= 1 1.0) ; T (numeric equality across types)
(< 1 2 3) ; T (chained)
(random 10) ; random integer 0..9
(random 1.0) ; random float in [0, 1)
(parse-integer "42") ; 42
(parse-
…