This module section introduces fundamental number systems essential for digital electronics: binary, hexadecimal, octal, and Gray code. Students will explore the binary number system, which forms the basis of computer operations, including its conversion to and from other number systems. Hexadecimal numbers, used for compact representation of binary data, and octal numbers, which provide a straightforward way to read and write binary values, will also be covered. Additionally, the module delves into Gray code, a binary numeral system where two successive values differ in only one bit, crucial for minimizing errors in digital circuits. Through theoretical explanations and practical examples, students will gain a comprehensive understanding of these number systems, their applications, and inter-conversions, laying the groundwork for advanced studies in digital systems and computer engineering.
A binary number is a number expressed in the base-2 numeral system or binary numeral system, a method of mathematical expression which uses only two symbols: typically “0” (zero) and “1” (one).
The binary number system is a Base-2 numbering system which follows the same set of rules in mathematics as the commonly used decimal or base-10 number system.
So instead of powers of ten, ( \(10^n\) ) for example: 1, 10, 100, 1000 etc, binary numbers use powers of two, ( \(2^n\) ) effectively doubling the value of each successive bit as it goes, for example: 1, 2, 4, 8, 16, 32 etc.
The system of using Binary Numbers ideal for use in digital or electronic circuits and systems, because there are only two valid Boolean values for representing either a logic “1” or a logic “0”,(i.e. on and off).
Binary addition, binary subtraction, binary multiplication and binary division are the four types of arithmetic operations that occur in the binary arithmetic.
\begin{itemize} * 0 + 0 = 0 * 0 + 1 = 1 * 1 + 0 = 1 * 1 + 1 = 0 \ (and carry 1 to the next more significant bit) * 1 + 1 + 1 = 1 \ (and carry 1 to the next more significant bit)
Add the following pairs of binary numbers.
\(111_{(2)} + 1110_{(2)}\)
\(11010_{(2)} + 1100_{(2)}\)
\(10011_{(2)} + 111110_{(2)}\)
Align the numbers you wish to add from the right hand side.
Start with the two numbers in the far right column, and work towards the left-hand side.
(For ease of use, we add a zero to have the same number of digits )
\[ 0 1 1 1\] \[ 1 1 1 0\]
\(111_{(2)} + 1110_{(2)}\)}
\[ 0 1 1 1\] \[ 1 1 1 0\]
\(11010_{(2)} + 1100_{(2)}\)}
\[ 11010\] \[ 01100\]
\[ 010011\] \[ 111110\]
Hexadecimal (or simply “hex”) is a base-16 number system. It uses 16 distinct symbols: the digits 0-9 and the letters A-F, where A stands for 10, B for 11, C for 12, D for 13, E for 14, and F for 15. Hexadecimal is often used in computing and digital electronics because it can represent large binary numbers more compactly.
To convert a binary number to hexadecimal, group the binary digits into sets of four (starting from the right). Each group of four binary digits corresponds to a single hexadecimal digit.
Example 1: Convert Binary to Hexadecimal Binary
number: 101101101010
1. Group the binary digits into sets
of four: 1011 0110 1010
2. Convert each group to
hexadecimal: - 1011
= B
- 0110
=
6
- 1010
= A
3. So,
101101101010
in binary is B6A
in
hexadecimal.
Example 2: Convert Hexadecimal to Binary Hexadecimal
number: 4F3
1. Convert each hex digit to its binary
equivalent: - 4
= 0100
- F
=
1111
- 3
= 0011
2. Combine the
binary groups: 0100 1111 0011
3. So, 4F3
in
hexadecimal is 010011110011
in binary.
To convert a decimal number to hexadecimal, repeatedly divide the number by 16 and keep track of the remainders. The hexadecimal number is obtained by reading the remainders in reverse order.
Example 3: Convert Decimal to Hexadecimal Decimal
number: 254
1. Divide by 16: \(254 \div 16 = 15\) remainder \(14\) (E) 2. Divide the quotient by 16:
\(15 \div 16 = 0\) remainder \(15\) (F) 3. So, 254
in decimal
is FE
in hexadecimal.
Example 4: Convert Hexadecimal to Decimal
Hexadecimal number: 1A3
1. Convert each hex digit to
decimal and multiply by the corresponding power of 16: - 1
= 1 \(\times 16^2 = 256\) -
A
= 10 \(\times 16^1 =
160\) - 3
= 3 \(\times
16^0 = 3\) 2. Sum the results: \(256 +
160 + 3 = 419\) 3. So, 1A3
in hexadecimal is
419
in decimal.
#FFFFFF
for
white).110101011
to
hexadecimal.3C9
to binary.456
to hexadecimal.2F
to decimal.The hexadecimal numeral system, often shortened to “hex”, is a numeral system made up of 16 symbols (base 16). The standard numeral system is called decimal (base 10) and uses ten symbols: 0,1,2,3,4,5,6,7,8,9.
Hexadecimal uses the decimal numbers and six extra symbols. There are no numerical symbols that represent values greater than nine, so letters taken from the English alphabet are used, specifically A, B, C, D, E and F. Hexadecimal A = decimal 10, and hexadecimal F = decimal 15.
To avoid confusion with decimal, octal or other numbering systems, hexadecimal numbers are sometimes written with a “h” after or “0x” before the number. For example, 63h and 0x63 mean 63 hexadecimal.
Using the method of repeated division, or otherwise, convert the decimal number 4768 to base 8, showing all your workings. |
\[ \begin{array}{|c||c|c|c||l c|} \hline 4768 & 596 & 596 & 0 & \textit{$(0 \times 8)$}& 0 \\ \hline 596 & 74.5 & 74 & 0.5 &$(0.5 \times 8)$& 4 \\ \hline 74 & 9.25 & 9 & 0.25 &$(0.25 \times 8)$& 2 \\ \hline 9 & 1.125 & 1 & 0.125 &$(0.125 \times 8)$& 1 \\ \hline 1 & 0.125 & 0 & 0.125 &$(0.125 \times 8)$& 1 \\ \hline \end{array} \] |
Remark: Answer : 11240 |
### Octal Numbers - Videos |
* Converting Hexadecimal Numbers To Octal - Worked Example 1 * Converting Hexadecimal Numbers To Octal - Worked Example 2 * Converting Hexadecimal Numbers To Octal - Worked Example 3 |
Gray Code {data-navmenu=“Other Systems”} ================================== |
Column{.tabset} |
The reflected binary code (RBC), also known just as reflected binary (RB) or Gray code after Frank Gray, is an ordering of the binary numeral system such that two successive values differ in only one bit (binary digit).
For example, the representation of the decimal value “1” in binary would normally be “001” and “2” would be “010”.
In Gray code, these values are represented as “001” and “011”. That way, incrementing a value from 1 to 2 requires only one bit to change, instead of two.
Gray codes are widely used to prevent spurious output from electromechanical switches and to facilitate error correction in digital communications such as digital terrestrial television and some cable TV systems.
Here is an example of generating Gray code, which is a binary numeral system where two successive values differ in only one bit.
First, list all the 3-bit binary numbers in standard order:
000, 001, 010, 011, 100, 101, 110, 111
To convert these binary numbers to Gray code, follow the rule where the first bit remains the same, and each subsequent bit is obtained by XOR’ing the previous bit with the current bit.
Let’s go through each binary number:
First bit remains the same: 0
Second bit: \(0 \oplus 0 = 0\)
Third bit: \(0 \oplus 0 = 0\)
Gray code: 000
First bit remains the same: 0
Second bit: \(0 \oplus 0 = 0\)
Third bit: \(0 \oplus 1 = 1\)
Gray code: 001
First bit remains the same: 0
Second bit: \(0 \oplus 1 = 1\)
Third bit: \(1 \oplus 0 = 1\)
Gray code: 011
First bit remains the same: 0
Second bit: \(0 \oplus 1 = 1\)
Third bit: \(1 \oplus 1 = 0\)
Gray code: 010
First bit remains the same: 1
Second bit: \(1 \oplus 0 = 1\)
Third bit: \(1 \oplus 0 = 1\)
Gray code: 110
First bit remains the same: 1
Second bit: \(1 \oplus 0 = 1\)
Third bit: \(1 \oplus 1 = 0\)
Gray code: 111
First bit remains the same: 1
Second bit: \(1 \oplus 1 = 0\)
Third bit: \(0 \oplus 1 = 1\)
Gray code: 101
First bit remains the same: 1
Second bit: \(1 \oplus 1 = 0\)
Third bit: \(0 \oplus 1 = 1\)
Gray code: 100
Here is the 3-bit Gray code sequence:
000, 001, 011, 010, 110, 111, 101, 100
By following the rule of keeping the first bit the same and XOR’ing subsequent bits, we have successfully converted 3-bit binary numbers into Gray code. This sequence ensures that only one bit changes between consecutive values.
Decimal | Binary | Hexadecimal | Octal | Binary with 4 digits | |
---|---|---|---|---|---|
Base 10 | Base 2 | Base 16 | Base 8 | Base 2 | |
0 | 0 | 0 | 0 | 0000 | |
1 | 1 | 1 | 1 | 0001 | |
2 | 10 | 2 | 2 | 0010 | |
3 | 11 | 3 | 3 | 0011 | |
4 | 100 | 4 | 4 | 0100 | |
5 | 101 | 5 | 5 | 0101 | |
6 | 110 | 6 | 6 | 0110 | |
7 | 111 | 7 | 7 | 0111 | |
8 | 1000 | 8 | 10 | 1000 | |
9 | 1001 | 9 | 11 | 1001 | |
10 | 1010 | A | 12 | 1010 | |
11 | 1011 | B | 13 | 1011 | |
12 | 1100 | C | 14 | 1100 | |
13 | 1101 | D | 15 | 1101 | |
14 | 1110 | E | 16 | 1110 | |
15 | 1111 | F | 17 | 1111 |
Part (a) How many Symbols are used in each System
State which of the following sets the following numbers belong to.
[1)] \(18\) [2)] \(8.2347\ldots\) [3)] \(\pi\) [4)] \(1.33333\ldots\) [5)] \(17/4\) [6)] \(4.25\) [7)] \(\sqrt{\pi}\) [8)] \(\sqrt{25}\)
The possible answers are
[a] Natural number : \(\mb{N} \subseteq \mb{Z } \subseteq \mb{Q} \subseteq \mb{R}\) [b] Integer : $ $ [c] Rational Number : $ $ [d] Real Number \(\mb{R}\)
\end{enumerate}
%\begin{framed}
\(\mb{N}\) : natural numbers (or positive integers) \(\{1,2,3,\ldots\}\)\(\mb{Z}\) : integers \(\{-3,-2,-1,0,1,2,3,\ldots\}\)
(The letter \(\mb{Z}\) comes from the word which means ``numbers” in German.)
\(\mb{Q}\) : rational numbers \(\mb{R}\) : real numbers\(\mb{N} \subseteq \mb{Z } \subseteq \mb{Q} \subseteq \mb{R}\)
(All natural numbers are integers. All integers are rational numbers. All rational numbers are real numbers.)
Express the following decimal numbers as binary numbers.
\((73)_{10}\) \((15)_{10}\)\((22)_{10}\)
All three answers are among the following options.
Express the following binary numbers as decimal numbers.
Express the following binary numbers as decimal numbers.
Express the following decimal numbers as binary numbers.
Perform the following binary additions.
Perform the following binary subtractions.
Perform the following binary multiplications.
Perform the following binary multiplications. %\begin{multicols}{2} % %a. \((1001000)_{2} \div ( 1000)_{2}\) %b. \((101101)_{2} \div (1001)_{2}\) %c. \((1001011000)_{2} \div (101000)_{2}\) %d. \((1100000)_{2} \div (10000)_{2}\) % %
Which of the following binary numbers is the result of this binary division: \((10)_{2} \times ( 1101)_{2}\). % % (2) / (13) \begin{multicols}{2}
Which of the following binary numbers is the result of this binary division: \((101010)_{2} \times( 111 )_{2}\). % (4) / (6) \begin{multicols}{2}
Which of the following binary numbers is the result of this binary division: \((1001110)_{2}\times ( 1101 )_{2}\). % (9) / (3) \begin{multicols}{2}
Perform the following binary divisions. %\begin{multicols}{2} % %a. \((1001000)_{2} \div ( 1000)_{2}\) %b. \((101101)_{2} \div (1001)_{2}\) %c. \((1001011000)_{2} \div (101000)_{2}\) %d. \((1100000)_{2} \div (10000)_{2}\) % %
\begin{enumerate}Which of the following binary numbers is the result of this binary division: \((111001)_{2} \div ( 10011)_{2}\). % (57) / (19) \begin{multicols}{2}
Which of the following binary numbers is the result of this binary division: \((101010)_{2} \div ( 111 )_{2}\). % (42) / (7) \begin{multicols}{2}
Which of the following binary numbers is the result of this binary division: \((1001110)_{2} \div ( 1101 )_{2}\). % (78) / (13) \begin{multicols}{2}
Answer the following questions about the hexadecimal number systems
Which of the following are not valid hexadecimal numbers?
Express the following decimal numbers as a hexadecimal number.
Compute the following hexadecimal calculations.
Express the following decimal numbers as binary numbers.
\((73)_{10}\)
\((15)_{10}\)
\((22)_{10}\)
All three answers are among the following options.
a.\((10110)_{2}\) %22
b.\((1111)_{2}\) %15
\((1001001)_{2}\) %73
\((1000010)_{2}\) %64
Express the following binary numbers as decimal numbers
\(101\)
\(1101\)
\(11011\)
\(100101\)
Express the following binary numbers as decimal numbers.
a.\((101010)_{2}\)
b.\((10101)_{2}\)
c.\((111010)_{2}\)
Express the following binary numbers as decimal numbers.
a.\((110.10101)_{2}\)
b.\((101.0111)_{2}\)
\((111.01)_{2}\)
\((110.1101)_{2}\)
Express the following decimal numbers as binary numbers
Express the following decimal numbers as binary numbers.
a.\((27.4375)_{10}\)% b.\((5.625)_{10}\) c. \((13.125)_{10}\) d. \((11.1875)_{10}\)
Perform the following binary additions.
a.\((110101)_{2}\) + \((1010111)_{2}\) b.\((1010101)_{2}\) + \((101010)_{2}\) c. \((11001010)_{2}\) + \((10110101)_{2}\) d. \((1011001)_{2}\) + \((111010)_{2}\)
Perform the following binary subtractions.
%http://www.csgnetwork.com/binaddsubcalc.html (See section 1.1.3 of the text)
Which of the following binary numbers is the result of this binary multiplication: \((10)_{2} \times ( 1101)_{2}\). % % (2) / (13)
Which of the following binary numbers is the result of this binary multiplication: \((1001110)_{2}\times ( 1101 )_{2}\). % (9) / (3)
Which of the following binary numbers is the result of this binary division: \((111001)_{2} \div ( 10011)_{2}\). % (57) / (19)
Which of the following binary numbers is the result of this binary division: \((101010)_{2} \div ( 111 )_{2}\). % (42) / (7)
Which of the following binary numbers is the result of this binary division: \((1001110)_{2} \div ( 1101 )_{2}\). % (78) / (13)
Which of the following binary numbers is the result of this binary division: \((1001110)_{2}\times ( 1101 )_{2}\). % (9) /(3)
a.\((11000)_{2}\) %24 b.\((11001)_{2}\) %25 c. \((10101)_{2}\) %21 d. \((11011)_2\) %27
Which of the following binary numbers is the result of this binary division: \((101010)_{2} \times( 111 )_{2}\).
% (4) /(6)
a.\((11000)_{2}\) %24 b.\((11001)_{2}\) %25 c. \((10101)_{2}\) %21 d. \((11011)_2\) %27
Which of the following binary numbers is the result of this binary division: \((1001110)_{2}\times ( 1101 )_{2}\). % (9) /(3)
a.\((11000)_{2}\) %24 b.\((11001)_{2}\) %25 c. \((10101)_{2}\) %21 d. \((11011)_2\) %27
Which of the following binary numbers is the result of this binary division: \((1001110)_{2}\times ( 1101 )_{2}\). % (9) /(3)
a.\((11000)_{2}\) %24 b.\((11001)_{2}\) %25 c. \((10101)_{2}\) %21 d. \((11011)_2\) %27
Perform the following binary divisions.
a.\((1001000)_{2} \div ( 1000)_{2}\) b.\((101101)_{2} \div (1001)_{2}\) c. \((1001011000)_{2} \div (101000)_{2}\) d. \((1100000)_{2} \div (10000)_{2}\)
Express the following binary numbers as decimal numbers
( i) \(101\) ( ii) \(1101\) ( iii) \(11011\) ( iv) \(100101\)
( b) Express the following decimal numbers as binary numbers
( i) 6 ( ii) 15 ( iii) 37 ( iv) 77
A number is expressed in base 5 as \((234)_5\). What is it as decimal number? Suppose you multiply \((234)_5\) by 5. what would be the answer in base 5.
Perform the following binary additions
\(1011 + 1111\)
\(10101 + 10011\)
\(1010 + 11010\)
\(101010 + 10101 + 101\)
Perform the binary additions
\((10111)_2 +(111010)_2\)
\((1101)_2 + (1011)_2 + (1111)_2\)
Perform the binary subtractions using both the bit-borrowing method and the two’s complement method.
\((1001)_2 -(111)_2\)
\((110000)_2 -(10111)_2\)
Perform the binary multiplications
\((1101)_2 \times (101)_2\)
\((1101)_2 \times (1101)_2\)
( a) What is highest Hexadecimal number that can be written with two characters, and what is it’s equivalent in decimal form? What is the next highest hexadecimal number?
% \[FF = 255\] % Remark ( b) Which of the following are not valid hexadecimal numbers?
( i) A5G ( ii) 73 ( iii) EEF ( iv) 101
( i) 110 - 10 ( ii) 101 - 11
( iii) 1001 - 11 ( iv) 10001 - 100 ( v) 101001 - 1101 ( vi)
11010101-1101
( a) Suppose 2341 is a base-5 number Compute the equivalent in each of the following forms:
( i) decimal number ( ii) hexadecimal number ( iii) binary number
( b) Perform the following binary additions
( i) \(1011+ 1111\) ( ii) \(10101 + 10011\) ( iii) \(1010 + 11010\)
Perform the following binary multiplications.
Perform the following binary divisions.
Which of the following binary numbers is the result of this binary division: \((111001)_{2} \div ( 10011)_{2}\). (57) / (19)
Which of the following binary numbers is the result of this binary division: \((101010)_{2} \div ( 111 )_{2}\). (42) / (7)
Which of the following binary numbers is the result of this binary division: \((1001110)_{2} \div ( 1101 )_{2}\). (78) / (13)
Perform the following binary multiplications.
\((1001000)_{2} \div ( 1000)_{2}\)
\((101101)_{2} \div (1001)_{2}\)
\((1001011000)_{2} \div (101000)_{2}\)
\((1100000)_{2} \div (10000)_{2}\)
Perform the following binary division exercises.
\((1001000)_{2} \div ( 1000)_{2}\)
\((101101)_{2} \div (1001)_{2}\)
\((1001011000)_{2} \div (101000)_{2}\)
\((1100000)_{2} \div (10000)_{2}\)
Calculate working in hexadecimal
\((BBB)_{16} + (A56)_{16}\)\((BBB)_{16} - (A56)_{16}\)
Write the hex number \((EC4)_{16}\) in binary. Write the binary number \((11110110101|)_2\) in hex.
Express the decimal number 753 in binary , base 5 and hexadecimal.
Express 42900 as a product of its prime factors, using index notation for repeated factors.
Expresse the recuring decimals
( i) \(0.727272\ldots\) ( ii) \(0.126126126....\) ( iii) \(0.7545454545...\)
as rational numbers in its simplest form.
Given that \(\pi\) is an irrational number, can you say whether \(\frac{\pi}{2}\) is rational or irrational. or is it impossible to tell?
Given x is the irrational positive number \(\sqrt{2}\), express \(x^8\) in binary notation
From part (i), is \(x^8\) a rational number?
Write down the numbers 0.0000526 in floating point form.
How is the number 1 expressed in floating point form.
Deduce that every composite integer \(n\) has a prime factor such that \(p \leq \sqrt{n}\).
Decide whether 899 is a prime.
What would be the maximum numbber of digits that a decimal fraction with denominator 13 could have in a recurring block in theory?
Can you predict which other fractions with denominator 13 will have the same digits as 1/13 in their recurring block?
Perform the following binary subtractions.
Perform the binary subtractions using both the bit-borrowing method and the two’s complement method.
Express the following decimal numbers as binary numbers.
All three answers are among the following options.
Express the following binary numbers as decimal numbers.
Express the following binary numbers as decimal numbers.
Express the following decimal numbers as binary numbers.
\((73)_{10}\) \((15)_{10}\)\((22)_{10}\)
All three answers are among the following options.
Express the following binary numbers as decimal numbers.
Express the following binary numbers as decimal numbers.
Express the following decimal numbers as binary numbers.
Perform the following binary multiplications. % % %(a) \((1001000)_{2} \div ( 1000)_{2}\) %(b) \((101101)_{2} \div (1001)_{2}\) %(c) \((1001011000)_{2} \div (101000)_{2}\) %(d) \((1100000)_{2} \div (10000)_{2}\) % %
%
Perform the following binary divisions.
%(a) \((1001000)_{2} \div ( 1000)_{2}\) %(b) \((101101)_{2} \div (1001)_{2}\) %(c) \((1001011000)_{2} \div (101000)_{2}\) %(d) \((1100000)_{2} \div (10000)_{2}\)
%http://www.csgnetwork.com/binaddsubcalc.html (See section 1.1.3 of the text)
Perform the following binary additions.
Perform the following binary subtractions.
Perform the following binary multiplications.
Perform the following binary multiplications. % % %a. \((1001000)_{2} \div ( 1000)_{2}\) %b. \((101101)_{2} \div (1001)_{2}\) %c. \((1001011000)_{2} \div (101000)_{2}\) %d. \((1100000)_{2} \div (10000)_{2}\) % %
Which of the following binary numbers is the result of this binary division: \((10)_{2} \times ( 1101)_{2}\). % % (2) / (13)
Which of the following binary numbers is the result of this binary division: \((101010)_{2} \times( 111 )_{2}\). % (4) / (6)
Which of the following binary numbers is the result of this binary division: \((1001110)_{2}\times ( 1101 )_{2}\). % (9) / (3)
%—————————————————————-%
Perform the following binary divisions. % % %a. \((1001000)_{2} \div ( 1000)_{2}\) %b. \((101101)_{2} \div (1001)_{2}\) %c. \((1001011000)_{2} \div (101000)_{2}\) %d. \((1100000)_{2} \div (10000)_{2}\) % %
Which of the following binary numbers is the result of this binary division: \((111001)_{2} \div ( 10011)_{2}\). % (57) / (19)
Which of the following binary numbers is the result of this binary division: \((101010)_{2} \div ( 111 )_{2}\). % (42) / (7)
Which of the following binary numbers is the result of this binary division: \((1001110)_{2} \div ( 1101 )_{2}\). % (78) / (13)
#### *{Question 1} |
* When is the positive integer \(p\) said to be a prime number? * Express the following hexadecimal number as a decimal number, and as a binary number: \[(A32.8)_{16}\] |
* Convert the following decimal number into base 2, showing all your working: \((253)_{10}\). * Covert the decimal integer \((407)_{10}\) to binary notation. |
* Showing your working, express the following number \[ 1.024024024024\ldots\] as a ration number in its simplest form. * Compute the following \(101101_2 + 1101_2\) |
Hexadecimal Numbers - Worksheet 1 {data-navmenu=“Exercises”} ================================== |
Column {.tabset} |
How many characters are used in the hexadecimal system?
What is highest hexadecimal number that can be written with two characters?
What is the equivalent number in decimal form?
What is the next highest hexadecimal number?
\(73\)
\(A5G\)
\(11011\)
$EEF $
\[44321\]
\[AA3 \times F\]
% \[FF = 255\] % Remark
[(i)] Calculate the decimal equivalent of the hexadecimal number \((A2F.D)_{16}\)
[(ii)] Working in base 2, compute the following binary additions, showing all you workings \[(1110)_2 + (11011)_2 + (1101)_2 \]
[(iv)] Express the recurring decimal \(0.727272\ldots\) as a rational number in its simplest form.
%Base 5 and Base 8 numbers Suppose 2341 is a base-5 number. Compute the equivalent in each of the following forms:
[(i)] decimal number
[(ii)] hexadecimal number
[(iii)] binary number