SWAB

PLCopen motion icon

 Function - Swap the bytes of an integer.

Inputs

Input

Data Type

Range

Unit

Default

Description

IN

ANY

No range

N/A

No default

Any signed or unsigned integer.

Outputs

Output

Data Type

Range

Unit

Description

Q

ANY

No range

N/A

Swapped value.

Remarks

Supported data types are:

  • DINT
  • DWORD
  • INT
  • LINT
  • LWORD
  • SINT
  • UDINT
  • UINT
  • ULINT
  • USINT
  • WORD
  • SINT and USINT inputs result in the same output value because they are only 1 byte wide.
  • If the function is called for another data type, the output takes the value of the input.

Examples

Type

IN

Q

DWORD

16#1A2B3C4D

16#4D3C2B1A

WORD

16#1A2B

16#2B1A

FBD Language Example

FFLD Language Example

IL Language Example

Not available.

ST Language Example

swappedValue := SWAB(value);