Skip to main content

-

- Function

Syntax:

− number → negation

− minuend &rest subtrahends+ → difference

Arguments and Values:

number, minuend, subtrahend—a number .

negation, difference—a number .

Description:

The function - performs arithmetic subtraction and negation.

If only one number is supplied, the negation of that number is returned.

If more than one argument is given, it subtracts all of the subtrahends from the minuend and returns the result.

The function - performs necessary type conversions.

Examples:

(- 55.55)-55.55 
(- #c(3 -5)) → #C(-3 5)
(- 0)0
(eql (- 0.0) -0.0) → true
(- #c(100 45) #c(0 45))100
(- 10 1 2 3 4)0

Exceptional Situations:

Might signal type-error if some argument is not a number . Might signal arithmetic-error.

See Also:

Section 12.1.1 (Numeric Operations), Section 12.1.3 (Rational Computations), Section 12.1.4 (Floating-point Computations), Section 12.1.5 (Complex Computations)

Expanded Reference: -

Negation with a single argument

With one argument, - returns the negation of the number.

(- 5)
=> -5
(- -3)
=> 3
(- 0)
=> 0
(- 55.55)
=> -55.55

Subtraction with multiple arguments

With two or more arguments, - subtracts all subsequent arguments from the first.

(- 10 3)
=> 7
(- 10 1 2 3 4)
=> 0
(- 100 50 25)
=> 25

Rational subtraction

Subtraction with rationals produces exact results.

(- 1 1/3)
=> 2/3
(- 3/4 1/4)
=> 1/2
(- 1/6 1/3)
=> -1/6

Floating-point subtraction

When any argument is a float, the result follows floating-point contagion rules.

(- 10 2.5)
=> 7.5
(- 1.0d0 0.5)
=> 0.5d0

Complex number subtraction

- handles complex numbers by operating on real and imaginary parts.

(- #c(3 -5))
=> #C(-3 5)
(- #c(100 45) #c(0 45))
=> 100
(- #c(5 3) #c(2 1))
=> #C(3 2)