# Compare Numeric (CPN)/OP=46

### Format

OP AF BF A Syllable B Syllable

`OP = 46`

AF is the length of the A field. A value of 00 is equal to a length of 100 units (digits or characters as specified by the A address controller). AF may be indirect or may indicate that the A syllable is a literal.
BF is the length of the B field. A value of 00 is equal to a length of 100 units (digits or characters as specified by the B address controller). BF may be indirect.

The A Syllable is the address of the first data field to be compared. Address may be indexed, indirect or extended. The final address controller data type may be UN, SN or UA.

The B Syllable is the address of the second data field to be compared. Address may be indexed, indirect or extended. The final address controller data type may be UN, SN or UA.

### Function

The Compare Numeric instruction algebraically compares the numeric portion of the A data field in memory against the numeric portion of the B data field in memory.

The numeric portion of a UA data field consists of the least significant digit of each character (i.e. zone digits are ignored).

If the field lengths are unequal pad the shorter field with leading zeros to equal the length of the longer field. The length does not include the sign digit of a signed numeric (SN) data field.

Plus zero compares equal to minus zero.

UA and UN fields are assumed to have a positive sign.

The values in memory are unchanged.

### Comparison Flags

Set the Comparison Flags to HIGH if the algebraic value of the numeric portion of the A data field is greater than the numeric portion of the B data field. EQUAL if the numeric portion of the two data fields have exactly the same bit patterns (including leading zeros) and LOW if the algebraic value of the numeric portion of the A data field is less than the numeric portion of the B data field.

### Overlap

There are no overlap restrictions for this instruction.

### Examples

#### Example (1) Compare A Signed Numeric Field with an Unsigned Field

OP AFBF A Syllable B Syllable
46 AA05 =C20(SL) B Field (UN)
```                    BEFORE              AFTER
A Field           C20             unchanged
B Field         00015             unchanged```
`   Comparison Flags   nn                HIGH`

#### Example (2) Compare A Numeric Literal field with a Signed Field

OP AFBF A Syllable B Syllable
46 A602 =000012(NL) B Field (SN)
```                    BEFORE              AFTER
A Field          000012            unchanged
B Field            C25             unchanged```
`   Comparison Flags   nn                 LOW`

#### Example (3) Compare A Numeric Field with an Alpha Field

OP AFBF A Syllable B Syllable
46 0303 A Field (UN) B Field (UA)
```                    BEFORE              AFTER
A Field            213             unchanged
B Field          D2C1D4            unchanged```
`   Comparison Flags   nn                LOW`