Trident Help

RPN Advanced 42 manual · Chapter 12 of 18

Number bases and logic

Work in hexadecimal, octal and binary, and use AND, OR, XOR, NOT, bit test and rotate on 36-bit integers.

12.1The BASE menu#

Open BASE with shift 4. HEX, DEC, OCT and BIN switch the base used to type and show numbers. The annunciator shows HEX, OCT or BIN. In another base, numbers are 36-bit integers and are shown without a decimal part. Leaving the BASE menu with EXIT returns the calculator to decimal.

The BASE menu: A-F digits, HEX, DEC, OCT, BIN, LOGIC. The display shows: x: 0.0000 / A…F HEX DEC■OCT BIN LGC.
The BASE menu: A-F digits, HEX, DEC, OCT, BIN, LOGIC.

12.2Convert a number to another base#

Example 12.1

255 in hexadecimal

  1. Type 255 in decimal, then press HEX (second key).

    255ENTER⇧BASE41/x
Result of the example "255 in hexadecimal" The display shows: x: FF / A…F HEX■DEC OCT BIN LGC.
You should seeFF
Example 12.2

255 in octal

  1. Press OCT (fourth key).

    255⇧BASE4LOG
Result of the example "255 in octal" The display shows: x: 377 / A…F HEX DEC OCT■BIN LGC.
You should see377
Example 12.3

255 in binary

  1. Press BIN (fifth key).

    255⇧BASE4LN
Result of the example "255 in binary" The display shows: x: 11111111 / A…F HEX DEC OCT BIN■LGC.
You should see11111111
Example 12.4

Hexadecimal digits back to decimal

  1. Choose HEX, open A…F (first key) and press F twice (sixth key), leave that menu, then press DEC (third key).

    ⇧BASE41/xΣ+XEQXEQEXIT√x
Result of the example "Hexadecimal digits back to decimal" The display shows: x: 255.0000 / A…F HEX DEC■OCT BIN LGC.
You should see255.0000

12.3Type and calculate in a base#

Choose the base first, then type digits. Arithmetic works on integers; results are cut to whole numbers.

Example 12.5

Add in hexadecimal

  1. Choose HEX, type 15, ENTER, type 1 and add. 0x15 + 1 = 0x16.

    ⇧BASE41/x15ENTER1+
Result of the example "Add in hexadecimal" The display shows: x: 16 / A…F HEX■DEC OCT BIN LGC.
You should see16
Example 12.6

Multiply in hexadecimal

  1. 0x15 times 2 is 0x2A.

    ⇧BASE41/x15ENTER2×
Result of the example "Multiply in hexadecimal" The display shows: x: 2A / A…F HEX■DEC OCT BIN LGC.
You should see2A

12.4AND, OR, XOR, NOT, bit test and rotate#

The LOGIC menu (sixth key of BASE) has AND, OR, XOR, NOT, BIT? and ROTXY. Logic works on the 36-bit two's complement form of the numbers.

The LOGIC menu. The display shows: x: 0.0000 / AND  OR XOR NOT BIT ROT.
The LOGIC menu.
Example 12.7

12 AND 10

11002 AND 10102=100021100_2\ \text{AND}\ 1010_2=1000_2
  1. Type 12, ENTER, 10, open BASE, LOGIC, AND (first key).

    12ENTER10⇧BASE4XEQΣ+
Result of the example "12 AND 10" The display shows: x: 8.0000 / AND  OR XOR NOT BIT ROT.
You should see8.0000
Example 12.8

12 OR 10

  1. OR is the second key.

    12ENTER10⇧BASE4XEQ1/x
Result of the example "12 OR 10" The display shows: x: 14.0000 / AND  OR XOR NOT BIT ROT.
You should see14.0000
Example 12.9

12 XOR 10

  1. XOR is the third key.

    12ENTER10⇧BASE4XEQ√x
Result of the example "12 XOR 10" The display shows: x: 6.0000 / AND  OR XOR NOT BIT ROT.
You should see6.0000
Example 12.10

NOT 5

  1. NOT flips every bit: 5 becomes −6.

    5⇧BASE4XEQLOG
Result of the example "NOT 5" The display shows: x: -6.0000 / AND  OR XOR NOT BIT ROT.
You should see-6.0000
Example 12.11

Test bit 2 of 5

  1. Y = 5, X = bit number 2. BIT? (fifth key) answers Yes or No.

    5ENTER2⇧BASE4XEQLN
Result of the example "Test bit 2 of 5" The display shows: Yes / AND  OR XOR NOT BIT ROT.
You should seeYes
Example 12.12

Rotate right

  1. ROTXY rotates Y right by X bits: 1 rotated by 4 gives 2^32.

    1ENTER4⇧BASE4XEQXEQ
Result of the example "Rotate right" The display shows: x: 4,294,967,296.00 / AND  OR XOR NOT BIT ROT.
You should see4,294,967,296

HP-42S is a trademark of HP Inc.. Trident Calculator is an independent product by South View Studios and is not affiliated with, sponsored by or endorsed by HP. The name is used only to describe the kind of calculator this model resembles; Trident's names, keys, display, fonts and software are its own clean-room design.