Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Change language to: Français - Português - 日本語 - Русский
Scilab Help >> Scilab > Scilab keywords > minus

# minus

(-) subtraction operator. Sign change

```X - Y
-X```

### Arguments

X, Y

scalars, vectors, matrices, or hypermatrices of booleans, numbers, polynomials or rationals. They may also be some `syslin` lists.

### Description

Subtraction

For numeric operands, the subtraction has its usual meaning. If one of the operands is a scalar, then the substraction is performed with each component of the other operand.

As soon as a boolean is involved in a substraction with a number (decimal, complex, or encoded integer), it is automatically converted in the type (and integer type) of the number before performing the substraction or the sign change, as `%F => 0` and `%T => 1`.

Whatever is the (regular) type of `X`, then `[]-X`, `X-[]`, and `-[]` return `[]`.

The subtraction operator may be extended to other custom data types through the overloading mechanism.

### Examples

```[] - 2
1 - []
[2, 5] - 1
[2, 5] - [3 -2]

%s - 2
1/%s - 2```
```--> [] - 2
ans  =
[]

--> 1 - []
ans  =
[]

--> [2, 5] - 1
ans  =
1.   4.

--> [2, 5] - [3 -2]
ans  =
-1.   7.

--> %s - 2
ans  =
-2 +s

--> 1/%s - 2
ans  =
1 - 2s
-------
s
```

With booleans:

```-[%f %t]
[%f %f %t %t]  - [%f %t %f %t]
%t - %i
c = %t - int8(7), inttype(c)```
```--> -[%f %t]
ans  =
0.  -1.

--> [%f %f %t %t]  - [%f %t %f %t]
ans  =
0.  -1.   1.   0.

--> %t - %i
ans  =
1. - i

--> c = %t - int8(7), typeof(c)
c  =
-6

ans  =
int8
```

• plus — Numerical addition. Text concatenation (gluing)
• operators — scilab operator names
• oldEmptyBehaviour — Controls the operation+ and operation- behaviour for Scilab
• mtlb_s — Matlab subtraction emulation function

### History

 Version Description 6.0.0 `A - []` and `[] - A` now return `[]` instead of `A` or `-A`.