MOVE — Copy a Value
MOVE
Source
source
Dest
dest
Copies a source value (literal or tag) into a destination tag. When the source and destination are different numeric types, MOVE is also how you convert between them.
Operands
| Name | Type |
|---|---|
source | DINT | REAL |
dest | DINT | REAL |
How It Works
When the rung is true, source is read and written to dest every scan. When the rung is false, MOVE does nothing and dest keeps its last value.
Example — Change a Timer Preset at Run Time
Set a timer's preset based on which mode the machine is in.
XIC(ModeFast)MOVE(2000,CycleTimer.PRE);XIC(ModeSlow)MOVE(8000,CycleTimer.PRE)
While ModeFast is selected, CycleTimer.PRE is held at 2000. While ModeSlow is selected, it is held at 8000.
Example — Copy a Reading
XIC(SampleNow)MOVE(TempSensor,LastSample)
Type Conversion
Studio has no separate _TO_ conversion instructions (no REAL_TO_DINT, no DINT_TO_REAL). Conversion happens automatically when MOVE's source and destination types differ.
Conversion behavior in rungs.dev follows the same conventions as Studio 5000 Logix Designer®.
DINT → REAL (lossless for most values)
A DINT value is copied into a REAL with a decimal point added. For everyday values this is exact:
Source (DINT) | Destination (REAL) |
|---|---|
7 | 7.0 |
-1000 | -1000.0 |
16777216 | 16777216.0 |
A REAL can represent integers exactly up to about 16.7 million. Above that, the conversion is rounded to the nearest representable value. For example, 16777217 becomes 16777216.0. You'll only hit this with large counters or accumulators — for everyday tags it's not something to worry about.
REAL → DINT (banker rounding)
The fractional part has to go somewhere, so Studio uses banker rounding — also called round half to even. Halves go to the nearest even integer; non-halves round normally.
Source (REAL) | Destination (DINT) |
|---|---|
0.5 | 0 |
1.5 | 2 |
2.5 | 2 |
3.5 | 4 |
-2.5 | -2 |
1.4 | 1 |
1.6 | 2 |
MOVE(2.5, DintTag) // DintTag = 2
MOVE(3.5, DintTag) // DintTag = 4
For more on why halves round to the nearest even number rather than always up, see the Arithmetic and Comparison Operators page.
REAL → DINT overflow
After rounding, a finite REAL that is outside the DINT range overflows into the stored 32-bit DINT bit pattern. For example, 2147483648.0 stores as -2147483648.
REAL → DINT with non-finite values
If the source is +Infinity, -Infinity, or NaN (which can happen after a divide-by-zero), Studio clamps the value to the DINT range so an integer tag never holds a non-numeric value.
Source (REAL) | Destination (DINT) |
|---|---|
+Infinity | 2147483647 (MAX) |
-Infinity | -2147483648 (MIN) |
NaN | 0 |
Common Mistakes
- Moving a
REALinto aDINTdestination without expecting rounding — the fractional part is gone, and halves snap to the nearest even integer (so2.5 → 2, not3). - Treating
MOVEas a free transfer between any two types — it works for numbers (DINT↔REAL), but not for structured types likeTIMERorCOUNTER.
Related
- Compare instructions — inspect values rather than move them
- Math instructions — compute values, then
MOVEor assign directly - Arithmetic and Comparison Operators — full division, rounding, and coercion rules