HP 9g User manual

hp calculators
HP 9g Base Conversions and Arithmetic
Numbers in Different Bases
The Base-N Mode
Practice Working with Numbers in Different Bases

hp calculators
HP 9g Base Conversions and Arithmetic
Numbers in different bases
Our number system (called the Hindu-Arabic number system) is a decimal system (it’s also sometimes referred to as
denary system) because it counts in 10s and powers of 10. Its base, i.e. the number on which a number system is built,
is therefore 10. While base 10 numbers are extensively used, this not the only possible base. There have been number
systems with base 20 (Mayas), mixed bases of 10 and 60 (used by the Babylonians), of 5 and 10 (ancient Romans), etc.
Even nowadays the sexagesimal system (base 60) is used in some measurements of time and angle. The HP 9g
enables you to work with numbers that are expressed in base 2, base 8, base 10 and base 16 numbers. All these bases
are important in computing. Base 2 numbers are called binary numbers and their digits are limited to 1 and 0. A common
abbreviation of binary digit is bit, which is either 1 or 0. Base 8 are called octal numbers, whose digits are 0, 1, 2, 3, 4, 5,
6 and 7. Finally, base 16 numbers are called hexadecimal numbers: 0, 1, 2, ,3 ,4 ,5 ,6 ,7 ,8 ,9, A, B, C, D, E and F.
The main difference between all these numbers is the value a digit have because of its place in a numeral. For example,
in the decimal number 378 the digit 3 has value 300, 7 has value 70 and 8 has value 8. In other words:
012 108107103378 ⋅+⋅+⋅=
But if 378 were a hexadecimal number then its decimal value would be:
dh 888168167163378 012 =⋅+⋅+⋅=
A small h, b, d and o after or before a number mean that this number is expressed in hexadecimal, binary, decimal or
octal base respectively.
The Base-N mode
The HP 9g has a special operating mode in which binary, hexadecimal, octal and decimal operations and conversions
are performed: the Base-N mode. Press ` 2to set this mode. It works as the Main mode, there’s an entry line, in
which calculations are entered and a result line where results are displayed. In the left side of the display does always
appear a small h, b, d , and o: it is the current base, on which numbers are entered and results are displayed. To set the
current base press ~, or simply ,to display the “dhbo”menu and select DEC, HEX, BIN or OCT with the arrow
keys and press =. Bear in mind that only those digits allowable in the current digits can be entered: for example 102 is
an invalid number in binary mode, but you can enter numbers in a different base than the current one, by prefixing this
number by the letter corresponding to its base. These letters (p, d, h and b) are in the “dhbo” menu, displayed by ,.
Not all the operations and functions that are available in the Main mode are available in Base-N. The valid operations
are the basic arithmetic ( + * - /) and the functions MAX (YY0 ), MIN (YY1 ), SUM
(YY2 ) and AVG (YY3) in the MATH menu, as well as all the memory related operations (running
memory, variables, ANS). In addition to these operations, the HP 9g provides six logical operations which are described
in the learning module Logical Operations on Base-N Numbers. Even though basic arithmetic functions will work with
numbers in different bases, these numbers must be integers – both arguments and results. In fact, when Base-N mode
is active, the .key is disabled.
Base-N mode is assumed in all the following examples. To set this mode now press ` 2 .
hp calculators - 2 - HP 9g Base Conversions and Arithmetic - Version 1.0

hp calculators
HP 9g Base Conversions and Arithmetic
Practice working with numbers in different bases
Example 1: Enter the hexadecimal number F9014 and convert it to decimal.
Solution: First let’s set the calculator to decimal mode by pressing , select DEC with the arrow keys and finally
the =key. You can key numbers in any base into the entry line, but when their base is not the same as
the active base (which is displayed as a small annunciator in the display) the number should be prefixed
with a small letter identifying its own base. In this example, we need to specify that F9014 is a hex number:
, …†=j9014
hF9014 is now in the entry line. Note that hex digits A through F are keyed in by pressing the keys C,
D,E,H,I and J respectively. The ~key is not necessary. Now press =and the
number will appear converted into the decimal.
Answer: 1019924
Example 2: Convert the number in example 1 to octal and binary.
Solution: Once a number is displayed in the result line, the ,key behaves differently. It’s now an easy way of
converting numbers between the four bases. Press it now and you will see the menu “DH B O” The
underlined letter corresponds to the base in which the displayed number is. Press † and the number is
now F9014 – it is being now displayed in hex base. Press † again to view it in binary. The number
displayed is 00010100, but notice the small “1” that appears next to the base annunciator. This means that
what is displayed is not the complete number because it’s too big to fit in the result line. To view the other
digits press Ü (on the . key, pressing ~ is not necessary) up to four times: the digits that appear
are 10010000in the second screen (2b), 1111 in the third(3b) and 0 in the fourth (4b), which means that
1019924 inbinary base is 11111001000000010100. Let’s now convert this number to octal. This is as
simple as pressing †.
There are two ways to quit this menu: by pressing either :or =;the former cancels the currently
selected base (octal) and returns to the base that was set before starting this menu (decimal). The latter
makes the current base the active one. Let’s now press =.
Answer: 11111001000000010100 and 3710024.
Example 3: Add 7F6 base 16 to 1011001 base 2 and display the result in base 8.
Solution: Since base 8 has already been set in the previous example, let’s start keying in the calculation. Remember
that the hex number and the binary number will have to follow a small h and a small b respectively. For the
blinking cursor to appear press :, and then
,…†=7j6+,„=1011001=
Answer: 4117 in base 8.
Example 4: Multiply the previous answer by ABC in base 10. Express the result in base 10.
hp calculators - 3 - HP 9g Base Conversions and Arithmetic - Version 1.0

hp calculators
HP 9g Base Conversions and Arithmetic
Solution: The previous answer is stored in the ANS variable. So, just press:
* , „ „ = c d e =
To display the result in base 10 press:
,†
Answer: 5844996 base 10.
Example 5: Which of the following numbers is the greatest? d473, o712, b110101000 and h1D8.
Solution: We can use the MAX function to find the maximum of the given numbers. Press:
YY0473W0,‡†=712W0,„=110101
000W0,„„=1h8=
This results in d473 being displayed in the result line, which is therefore the greatest of the given numbers.
If the maximum had been another one, it would have been displayed in the activebase (decimal), and
pressing ,and selecting the different bases would have been required in order to identify the number.
Also note that up to ten arguments can be specified in the MAX function and that arguments are separated
by commas (W0).
Answer: d473.
Example 6: Subtract 42 base 8 from 101111 base 2 and then display the two's complement of the result in base 2.
Solution: We can do this calculation in one step using parentheses. The calculation in question is:
NEG( b101111 – o42)
NEG (i.e. m, on the Mkey. Pressing ~first is not necessary) calculates the two’s complement of
the argument (i.e. complements each bit and adds one). Note that parentheses are required because NEG
has priority over subtraction. Let’s make sure the calculator is in BIN mode, by pressing
,††=
and now we can enter and evaluate the above expression by pressing
m N101111-,‡†=42=
We need to press Üfour times to view the entire result , since it’s a 32-bit digit.
Answer: 11111111111111111111111111110011 base 2. This is equivalent to –13 in base 10.
hp calculators - 4 - HP 9g Base Conversions and Arithmetic - Version 1.0
Other manuals for 9g
10
Table of contents
Other HP Calculator manuals