NEG — Negate

Description
Section titled “Description”NEG (Negate) writes the arithmetic negative of Source to Dest every scan its rung is true: a positive value becomes negative and a negative value becomes positive. It is an output instruction with no state and no status bits. Use NEG to reverse a direction command, mirror an offset, or flip the sign of a correction. Do not confuse it with NOT, which inverts every bit of a word; NEG 5 is −5, NOT 5 is −6.
Operands
Section titled “Operands”| Operand | Type | Format | Valid Range | Required | Description |
|---|---|---|---|---|---|
| Source | Any numeric tag, member, element or bit, or a literal | Tag, Tag.Member, Tag[n], Tag.bit, or a literal |
Any resolvable numeric reference | Yes | The value to negate. |
| Dest | A writable numeric tag, member or element | Tag, Tag.Member, Tag[n] |
SINT, INT, DINT or REAL; not a literal, not an input pin | Yes | Where the negated value is written. |
Dest may be the same tag as Source, in which case the value flips sign on every scan the rung is true. Gate that with an ONS or it flips thousands of times a second.
Range edge. The most negative value of a whole-number type has no positive twin: NEG of −32768 in an INT wraps back to −32768. A REAL has no such edge.
Scan Behavior
Section titled “Scan Behavior”Prescan
Section titled “Prescan”Nothing. Dest keeps its power-up value.
Rung-condition-in is false
Section titled “Rung-condition-in is false”The instruction does nothing. Dest holds its last value.
Rung-condition-in is true
Section titled “Rung-condition-in is true”Source is read, its sign is reversed and the result is written to Dest every scan the rung is true.
Postscan
Section titled “Postscan”Nothing.
Example
Section titled “Example”Scenario: A positioning table applies a tool offset when travelling forward. On the return pass the same offset must be applied the other way.
Tags:
Reverse— Return pass, BOOLOffset— Tool offset in steps, INTNeg_Offset— Offset for the return pass, INT
Rung 1:
—] [Reverse———[NEG Offset Neg_Offset]———Scan 1 — Reverse = 0. Offset reads 250. The rung is false: Neg_Offset holds 0.

Scan 2 — Reverse = 1. Neg_Offset reads −250.

See Also
Section titled “See Also”- ABS — Absolute Value (the sign removed rather than reversed)
- SUB — Subtract (
SUB 0 Source Destis the same operation) - NOT — Bitwise NOT (inverts bits, not sign)
- Compute Instructions — Category index
Toggle sign. NEG Dir Dir behind an ONS alternates a direction value between +1 and −1 on each event.
The block never colours. Watch the rung wire and the Dest value line.
Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11