Next: , Previous: , Up: Numbers   [Contents][Index]


5.4.4 Arithmetic Functions

There are a number of functions which perform arithmetic operations on numbers, they take a varying number of values as their arguments returning a new number as their result. When given only exact arguments, an exact result will be returned.

Function: + number1 #!rest numbers

This functions adds its arguments then returns their sum.

Function: - number1 #!rest numbers

If this function is just given one argument (number1) that number is negated and returned. Otherwise each of numbers is subtracted from a running total starting with the value of number1.

(- 20)
    ⇒ -20

(- 20 10 5)
    ⇒ 5
Function: * number1 #!rest numbers

This function multiplies its arguments then returns the result.

Function: / number1 #!rest numbers

This function performs division, a running-total (initialised from number1 is successively divided by each of numbers then the result is returned.

(/ 100 2)
    ⇒ 50

(/ 200 2 5)
    ⇒ 20

(/ 3 2)
    ⇒ 3/2

(/ 3.0 2)
    ⇒ 1.5
Function: 1+ number

This function returns the result of adding one to number.

(1+ 42)
    ⇒ 43
Function: 1- number

Returns number minus one.