Skip to main content

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

NameType
sourceDINT | REAL
destDINT | 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.

Modeled on Studio 5000 Logix Designer

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)
77.0
-1000-1000.0
1677721616777216.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.50
1.52
2.52
3.54
-2.5-2
1.41
1.62
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)
+Infinity2147483647 (MAX)
-Infinity-2147483648 (MIN)
NaN0

Common Mistakes

  • Moving a REAL into a DINT destination without expecting rounding — the fractional part is gone, and halves snap to the nearest even integer (so 2.5 → 2, not 3).
  • Treating MOVE as a free transfer between any two types — it works for numbers (DINTREAL), but not for structured types like TIMER or COUNTER.