DIV — Divide

Description
Section titled “Description”DIV (Divide) writes Source A divided by Source B to Dest every scan its rung is true. It is an output instruction with no state and no status bits. Use DIV for an average, a rate, a ratio, or to split a total into equal parts. Do not use DIV when the divisor can be zero and Dest must change anyway; a zero divisor skips the write and Dest keeps its old value, so test the divisor first if that matters.
Operands
Section titled “Operands”| Operand | Type | Format | Valid Range | Required | Description |
|---|---|---|---|---|---|
| Source A | 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 dividend. |
| Source B | Same as Source A | Same | Any resolvable numeric reference; 0 skips the write | Yes | The divisor. |
| 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 quotient is written. |
Whole numbers and fractions. The type of Dest decides how the division is done:
| Sources | Dest | Result |
|---|---|---|
| Both whole numbers | INT, SINT or DINT | Whole-number division, truncated toward zero: 7 ÷ 2 is 3, −7 ÷ 2 is −3. |
| Both whole numbers | REAL | Floating-point division: 7 ÷ 2 is 3.5. |
| Either a REAL | any | Floating-point division; a whole-number Dest then truncates toward zero. |
There is no remainder output. To get one, multiply the truncated quotient back and subtract, or use CPT with TRN.
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”Both sources are read. If Source B is not zero the quotient is written to Dest. If Source B is zero nothing is written, Dest holds, and there is no fault.
Postscan
Section titled “Postscan”Nothing.
Example
Section titled “Example”Scenario: A delivery van logs kilometres and hours per trip. At the end of the trip the average speed is calculated for the run sheet.
Tags:
Trip_End— Trip complete, BOOLOdo_km— Kilometres this trip, INTHours— Hours this trip, INTAvg_kmh— Average speed, REAL
Rung 1:
—] [Trip_End———[DIV Odo_km Hours Avg_kmh]———Scan 1 — Trip_End = 0. Odo_km reads 150 and Hours reads 4. The rung is false: Avg_kmh holds 0.

Scan 2 — Trip_End = 1. 150 ÷ 4 is written. Both sources are whole numbers, but Avg_kmh is a REAL, so the division keeps the fraction: 37.5.

Had Avg_kmh been declared INT, the same rung would show 37. Had Hours been 0, the rung would run and write nothing.
See Also
Section titled “See Also”- MUL — Multiply
- CPT — Compute (division inside a longer expression;
|is the divide symbol there) - SCP — Scale with Parameters (a ratio with an offset)
- NEQ — Not Equal (guard a divisor against zero)
- Compute Instructions — Category index
Zero divisor. RSLogix 500 faults the processor’s math overflow bit and writes the largest value; LadderIDE skips the write and leaves Dest alone, so a display keeps showing the last good value. Put NEQ Hours 0 ahead of the DIV when a stale value would mislead.
Remainder. Total ÷ 8 into an INT gives the whole quotient. The remainder is Total − Quotient × 8, two more instructions, or a single CPT Total − TRN(Total | 8) * 8.
Large DINT values. A REAL holds about seven significant digits. Dividing a DINT in the tens of millions into a REAL Dest loses the last digits; keep a DINT Dest for exact whole-number results.
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