# Math (Hex)

Instructions · `Math (Hex)` · verification: source checked

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.

## Specification

| Property | Value |
|---|---|
| Language | ladder |
| Code | Math (Hex) |

### Parameters

| Name | Description |
|---|---|
| Result | Memory address where the result will be stored; the result is stored in hex data format. The Browse Button opens Address Picker. |
| Type | Selecting Decimal or Hex determines the mathematical operations available; changing this selection after beginning the formula erases the formula. |
| One Shot | Solve the formula only once after each OFF-to-ON transition of the enabling rung. |
| Error Flags | System bits that turn ON when the specified condition has occurred. |
| Address or Nickname | Data registers can be identified in the formula by the memory address or nickname. |
| Formula Pad | Create the mathematical expression using the onscreen keypad, keyboard, and Address Picker. |
| Hex Keypad | Numeric 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.

## Sources

1. [Related Topics:](https://cdn.automationdirect.com/static/helpfiles/click/Content/203.htm) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/click-hex  
JSON: https://machineschema.com/instruction/click-hex.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
