Truncate (TRUNC)
When enabled, the TRUNC instruction removes (truncates) the fractional part of the Source and stores the result in the Destination.
Truncating does not round the value; rather, the non-fractional part remains the same, regardless of the value of the fractional part.
Available Languages
Ladder Diagram
Operands
IMPORTANT:
Unexpected operation may occur if:
- Output tag operands are overwritten
- Members of a structure operand are overwritten
- Except when specified, structure operands are shared by multiple instructions.
There are data conversion rules for mixing numeric data types within an instruction. See Data conversions.
Ladder Diagram
Operand | Data Type | Format | Description |
---|---|---|---|
Source | REAL LREAL | immediate tag | Value to truncate. |
Destination | SINT INT DINT LINT USINT UINT UDINT ULINT REAL LREAL | tag | Tag to store the result of the instruction. |
Affects Math Status Flags
Conditional. See Math status flags.
Major/Minor Faults
Execution
Ladder Diagram
Condition/State | Action Taken |
---|---|
Prescan | N/A. |
Rung-condition-in is false | Set Rung-condition-out to Rung-condition-in. |
Rung-condition-in is true | Set Rung-condition-out to Rung-condition-in. Dest = Truncated value of the Source. |
Postscan | N/A. |
Example
Ladder Diagram
Provide Feedback