The '/' function divides the first number given by the rest of the numbers and returns the result. If all the expressions are integers, the division is integer division. If any expression is a floating point number, then the division will be floating point division.
(/ 1) ; returns 1 (/ 1 2) ; returns 0 (integer division) (float (/ 1 2)) ; returns 0 (integer division) (/ (float 1) 2) ; returns 0.5 (/ 1 1.0 2) ; returns 0.5 (short cut) (/ (float 1) 2 3) ; returns 0.166667 (/ 1 1.0 2 3 4) ; returns 0.0416667 (print (+ 1 2 (* 3.5 (/ 3.9 1.45)))) ; returns and prints 12.4138
Common Lisp: Common Lisp supports a ratio data type. This means
that
Note: An easy way to force a sequence of integers to be divided as floating point numbers is to insert the number 1.0 after the first argument in the list of arguments to the divider function.
See the