# System.Dec

Object Pascal

```
function Dec(var X: Ordinal; [ N: Integer]): Integer; overload;
function Dec(var X: Ordinal; [ N: Integer]): Integer; overload;
```

#### Properties

Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|

function | public | System.pas | System | System |

## Description

Decrements a variable by 1 or N.

In Object Pascal code, Dec subtracts one or N from a variable.

X is a variable of an ordinal type (including Int64), or a pointer type if the extended syntax is enabled.

N is an integer-type expression.

X decrements by 1, or by N if N is specified; that is, Dec(X) corresponds to the statement X := X - 1, and Dec(X,N) corresponds to the statement X := X - N. On some platforms, Dec may generate optimized code, especially useful in tight loops.

If X is a pointer type, it decrements X by N times the size of the type pointed to. Thus, given:

type PMyType = ^TMyType;

and

var P: PMyType;

the statement Dec(P) decrements P by SizeOf(TMyType).

Warning:Do not use Dec on ordinal-type properties if the property uses a write procedure.