Math (Hex)

Math (Hex) is a ladder program instruction that solves a user-defined formula using hexadecimal data. The result is stored at a selected memory address in hex format. It supports nested parenthetical expressions and a set of hex arithmetic, logical, shift, rotate, range, and random operators.

Source checked16/16 values · 2026-10-26

Specification

1 source
Languageladder
CodeMath (Hex)

Parameters

NameDescription
ResultMemory address where the result will be stored; the result is stored in hex data format. The Browse Button opens Address Picker.
TypeSelecting Decimal or Hex determines the mathematical operations available; changing this selection after beginning the formula erases the formula.
One ShotSolve the formula only once after each OFF-to-ON transition of the enabling rung.
Error FlagsSystem bits that turn ON when the specified condition has occurred.
Address or NicknameData registers can be identified in the formula by the memory address or nickname.
Formula PadCreate the mathematical expression using the onscreen keypad, keyboard, and Address Picker.
Hex KeypadNumeric and letter keys for hex numbers, Sum and Modulo, parentheses, and certain logical operators and bit operators.

Study notes

  • Parenthetical expressions can be nested up to eight levels deep.
  • If the Floating Point Data Type is used in any operation, all operations are based on Floating Point math; the solution is stored in the data format selected for Result.
  • Changing the Type selection after beginning to develop the formula erases the formula.
  • One Shot solves the formula only once after each OFF-to-ON transition of the enabling rung.
  • Error Flags are system bits that turn ON when the specified condition has occurred.
  • Data registers can be identified in the formula by memory address or nickname.
  • The Hex Keypad includes numeric and letter keys for hex numbers, Sum and Modulo, parentheses, logical operators, and bit operators.
  • Hex operators include parentheses, SUM, divide, multiply, subtract, add, MOD, OR, LSH, LRO, AND, XOR, RSH, RRO, MAX, MIN, MDN, AVG, and RAND.
  • MAX, MIN, MDN, AVG, and RAND are not supported on C0-0x Series CPUs.
  • Shift and rotate examples: DH1 = 45B1; RSH(DH1,1h) gives DH2 = 22D8h; RRO(DH1,1h) gives DH2 = A2D8h.
  • Example: when C1 transitions from OFF-to-ON, the formula is solved and the result is stored in DH101 as a Hex number.
  • A separate Math (Decimal) instruction is referenced for decimal operation.
↑↓ navigate↵ openesc close