Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Number Systems: Decimal, Binary, Octal, and Hexadecimal, Cheat Sheet of Fundamentals of Design

An introduction to positional number systems, focusing on decimal, binary, octal, and hexadecimal. It covers the basics of number systems, position value, and conversion between decimal and binary. Additionally, it discusses complements and coding. Useful for students in computer science and engineering.

Typology: Cheat Sheet

2020/2021

Uploaded on 01/25/2022

sahanads16
sahanads16 🇮🇳

2 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MODULE -1: - NUMBER REPRESENTATION
Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-
valued number system is called binary. There are many advantages of using a binary system. The
decimal number system contains 10 unique symbols (0 ! 9) commonly referred to as the Arabic
numerals. Each of these symbols is assigned a relative magnitude to the other symbols. For example, 0 is
less than 1, 1 is less than 2, etc. It is often conjectured that the 10-symbol number system that we
humans use is due to the availability of our ten fingers (or digits) to visualize counting up to 10.
Regardless, our brains are trained to think of the real world in terms of a decimal system. In order to
bridge the gap between the way our brains think (decimal) and how we build our computers (binary),
we need to understand the basics of number systems. This includes the formal definition of a positional
number system and how it can be extended to accommodate any arbitrarily large (or small) value. This
also includes how to convert between different number systems that contain different numbers of
symbols. In this chapter, we cover four different number systems: decimal (10 symbols), binary (2
symbols), octal (8 symbols), and hexadecimal (16 symbols). The study of decimal and binary is obvious as
they represent how our brains interpret the physical world (decimal) and how our computers work
(binary). Hexadecimal is studied because it is a useful means to represent large sets of binary values
using a manageable number of symbols. Octal is rarely used but is studied as an example of how the
formalization of the number systems can be applied to all systems regardless of the number of symbols
they contain. This chapter also discusses how to perform basic arithmetic in the binary number system
and represent negative numbers.
1.1 POSITIONAL NUMBER SYSTEM:
A positional number system allows the expansion of the original set of symbols so that they can be used
to represent any arbitrarily large (or small) value. For example, if we use the 10 symbols in our decimal
system, we can count from 0 to 9. Using just the individual symbols we do not have enough symbols to
count beyond 9. To overcome this, we use the same set of symbols but assign a different value to the
symbol based on its position within the number. The position of the symbol with respect to other
symbols in the number allows an individual symbol to represent greater (or lesser) values. We can use
this approach to represent numbers larger than the original set of symbols. For example, let’s say we
want to count from 0 upward by 1. We begin counting 0, 1, 2, 3, 4, 5, 6, 7, 8 to 9. When we are out of
symbols and wish to go higher, we bring on a symbol in a different position with that position being
valued higher and then start counting over with our original symbols (e.g., ..., 9, 10, 11,... 19, 20, 21, ...).
This is repeated each time a position runs out of symbols (e.g., ..., 99, 100, 101, ... 999, 1000, 1001, ...).
The first thing that is needed is a set of symbols. The formal term for one of the symbols in a number
system is a numeral. One or more numerals are used to form a number. We define the number of
numerals in the system using the terms radix or base
Radix= Base= the number of numerals in the number system.
For example, our decimal number system is said to be base 10, or have a radix of 10 because it consists
of 10 unique numerals or symbols. The next thing that is needed is the relative value of each numeral
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Understanding Number Systems: Decimal, Binary, Octal, and Hexadecimal and more Cheat Sheet Fundamentals of Design in PDF only on Docsity!

MODULE -1: - NUMBER REPRESENTATION

Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two- valued number system is called binary. There are many advantages of using a binary system. The decimal number system contains 10 unique symbols (0! 9) commonly referred to as the Arabic numerals. Each of these symbols is assigned a relative magnitude to the other symbols. For example, 0 is less than 1, 1 is less than 2, etc. It is often conjectured that the 10-symbol number system that we humans use is due to the availability of our ten fingers (or digits) to visualize counting up to 10. Regardless, our brains are trained to think of the real world in terms of a decimal system. In order to bridge the gap between the way our brains think (decimal) and how we build our computers (binary), we need to understand the basics of number systems. This includes the formal definition of a positional number system and how it can be extended to accommodate any arbitrarily large (or small) value. This also includes how to convert between different number systems that contain different numbers of symbols. In this chapter, we cover four different number systems: decimal (10 symbols), binary ( symbols), octal (8 symbols), and hexadecimal (16 symbols). The study of decimal and binary is obvious as they represent how our brains interpret the physical world (decimal) and how our computers work (binary). Hexadecimal is studied because it is a useful means to represent large sets of binary values using a manageable number of symbols. Octal is rarely used but is studied as an example of how the formalization of the number systems can be applied to all systems regardless of the number of symbols they contain. This chapter also discusses how to perform basic arithmetic in the binary number system and represent negative numbers. 1.1 POSITIONAL NUMBER SYSTEM: A positional number system allows the expansion of the original set of symbols so that they can be used to represent any arbitrarily large (or small) value. For example, if we use the 10 symbols in our decimal system, we can count from 0 to 9. Using just the individual symbols we do not have enough symbols to count beyond 9. To overcome this, we use the same set of symbols but assign a different value to the symbol based on its position within the number. The position of the symbol with respect to other symbols in the number allows an individual symbol to represent greater (or lesser) values. We can use this approach to represent numbers larger than the original set of symbols. For example, let’s say we want to count from 0 upward by 1. We begin counting 0, 1, 2, 3, 4, 5, 6, 7, 8 to 9. When we are out of symbols and wish to go higher, we bring on a symbol in a different position with that position being valued higher and then start counting over with our original symbols (e.g., ..., 9, 10, 11,... 19, 20, 21, ...). This is repeated each time a position runs out of symbols (e.g., ..., 99, 100, 101, ... 999, 1000, 1001, ...). The first thing that is needed is a set of symbols. The formal term for one of the symbols in a number system is a numeral. One or more numerals are used to form a number. We define the number of numerals in the system using the terms radix or base Radix= Base= the number of numerals in the number system. For example, our decimal number system is said to be base 10, or have a radix of 10 because it consists of 10 unique numerals or symbols. The next thing that is needed is the relative value of each numeral

with respect to the other numerals in the set. We can say 0 < 1 < 2 < 3, etc. to define the relative magnitudes of the numerals in this set. The numerals are defined to be greater or less than their neighbors by a magnitude of 1. For example, in the decimal number system each of the subsequent numerals is greater than its predecessor by exactly 1. When we define this relative magnitude we are defining that the numeral 1 is greater than the numeral 0 by a magnitude of 1; the numeral 2 is greater than the numeral 1 by a magnitude of 1, etc. At this point we have the ability to count from 0 to 9 by 1’s. We also have the basic structure for mathematical operations that have results that fall within the numeral set from 0 to 9 (e.g., 1 + 2 ¼ 3). In order to expand the values that these numerals can represent, we need to define the rules of a positional number system. 1.2.1 Decimal Number System (Base 10) : As mentioned earlier, the decimal number system contains 10 unique numerals (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9). This system is thus a base 10 or a radix 10 system. The relative magnitudes of the symbols are 0 < 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9. 1.2.2 Binary Number System (Base 2) : The binary number system contains two unique numerals (0 and 1). This system is thus a base 2 or a radix 2 system. The relative magnitudes of the symbols are 0 < 1. At first glance, this system looks very limited in its ability to represent large numbers due to the small number of numerals. When counting up, as soon as you count from 0 to 1, you are out of symbols and must increment the p + 1 position in order to represent the next number (e.g., 0, 1, 10, 11, 100, 101, ...); however, magnitudes of each position scale quickly so that circuits with a reasonable amount of digits can represent very large numbers. The term bit is used instead of digit in this system to describe the individual numerals and at the same time indicate the base of the number. Due to the need for multiple bits to represent meaningful information, there are terms dedicated to describe the number of bits in a group. When 4 bits are grouped together, they are called a nibble. When 8 bits are grouped together, they are called a byte. Larger groupings of bits are called words. The size of the word can be stated as either an n-bit word or omitted if the size of the word is inherently implied. For example, if you were using a 32-bit microprocessor, using the term word would be interpreted as a 32-bit word. For example, if there was a 32-bit grouping, it would be referred to as a 32-bit word. The leftmost bit in a binary number is called the most significant bit (MSB). The rightmost bit in a binary number is called the least significant bit (LSB). 1.2.3 Octal Number System (Base 8): The octal number system contains 8 unique numerals (0, 1, 2, 3, 4, 5, 6, 7). This system is thus a base 8 or a radix 8 system. The relative magnitudes of the symbols are 0 < 1 < 2 < 3 < 4 < 5 < 6 < 7. We use the generic term digit to describe the numerals within an octal number.

1.3.2 From Binary to Hexadecimal: Starting at the binary point and working left, separate the bits into groups of four and replace each group with the corresponding hexadecimal digit. (10001011) 2 = (1000 1011) = ( 8B) 16 1.3.3 From Octal to Binary : Replace each octal digit with the corresponding 3-bit binary string. (213) 8 = (010 001 011) = (10001011) 2 1.3.4 From Hexadecimal to Binary Replace each hexadecimal digit with the corresponding 4-bit binary string. ( 8B) 16 = (1000 1011) = (10001011) 2 1.3.5 Conversion of Decimal Numbers From Binary to Decimal 100010112 = 12 7 + 02 6 + 02 5 + 02^4 + 12^3 + 02^2 + 12 1 + 12**^0 = 128 + 8 + 2 + 1 COMPLEMENTS: A ones' complement system or ones' complement arithmetic is a system in which negative numbers are represented by the inverse of the binary representations of their corresponding positive numbers. In such a system, a number is negated (converted from positive to negative or vice versa) by computing its ones' complement. An N-bit ones' complement numeral system can only represent integers in the range −(2N−1−1) to 2N−1−1 while two's complement can express −2N−1^ to 2N−1−1.

Example: 0001 0110 22

  • 0000 0011 3 =========== ==== 0001 1001 25 2’s complement: In two's-complement representation, positive numbers are simply represented as themselves, and negative numbers are represented by the two's complement of their absolute value; two tables on the right provide examples for N = 3 and N = 8. In general, negation (reversing the sign) is performed by taking the two's complement. This system is the most common method of representing signed integers on computers.An N -bit two's-complement numeral system can represent every integer in the range −(2 N − 1) to +(2 N − 1 (^) − 1) while ones' complement can only represent integers in the range −(2 N − 1 (^) − 1) to +(2 N − 1 (^) − 1). The sum of a number and its two's complement will always equal 0 (since the last digit is truncated), and the sum of a number and its one's complement will always equal −0. Converting to two's complement representation[edit] In two's complement notation, a non-negative number is represented by its ordinary binary representation; in this case, the most significant bit is 0. Though, the range of numbers represented is not the same as with unsigned binary numbers. For example, an 8-bit unsigned number can represent the values 0 to 255 (11111111). However a two's complement 8-bit number can only represent positive integers from 0 to 127 (01111111), because the rest of the bit combinations with the most significant bit as '1' represent the negative integers −1 to −128. The two's complement operation is the additive inverse operation, so negative numbers are represented by the two's complement of the absolute value. From the ones' complement [edit] To get the two's complement of a binary number, the bits are inverted, or "flipped", by using the bitwise NOT operation; the value of 1 is then added to the resulting value, ignoring the overflow which occurs when taking the two's complement of 0. For example, using 1 byte, the decimal number 5 is represented by 0000 0101 2 The most significant bit is 0, so the pattern represents a non-negative value. To convert to −5 in two's-complement notation, the bits are inverted; 0 becomes 1, and 1 becomes 0: 1111 1010 2 At this point, the numeral is the ones' complement of the decimal value −5. To obtain the two's complement, 1 is added to the result, giving:

 Binary codes are suitable for the digital communications.  Binary codes make the analysis and designing of digital circuits if we use the binary codes.  Since only 0 & 1 are being used, implementation becomes easy. Classification of binary codes The codes are broadly categorized into following four categories.  Weighted Codes  Non-Weighted Codes  Binary Coded Decimal Code  Alphanumeric Codes  Error Detecting Codes  Error Correcting Codes Weighted Codes Weighted binary codes are those binary codes which obey the positional weight principle. Each position of the number represents a specific weight. Several systems of the codes are used to express the decimal digits 0 through 9. In these codes each decimal digit is represented by a group of four bits. Non-Weighted Codes In this type of binary codes, the positional weights are not assigned. The examples of non-weighted codes are Excess-3 code and Gray code. Excess-3 code The Excess-3 code is also called as XS-3 code. It is non-weighted code used to express decimal numbers. The Excess-3 code words are derived from the 8421 BCD code words adding (0011)2 or (3)10 to each code word in 8421. The excess-3 codes are obtained as follows −

Example Gray Code It is the non-weighted code and it is not arithmetic codes. That means there are no specific weights assigned to the bit position. It has a very special feature that, only one bit will change each time the decimal number is incremented as shown in fig. As only one bit changes at a time, the gray code is called as a unit distance code. The gray code is a cyclic code. Gray code cannot be used for arithmetic operation. Application of Gray code  Gray code is popularly used in the shaft position encoders.  A shaft position encoder produces a code word which represents the angular position of the shaft. Binary Coded Decimal (BCD) code In this code each decimal digit is represented by a 4-bit binary number. BCD is a way to express each of the decimal digits with a binary code. In the BCD, with four bits we can represent sixteen numbers

ERROR DETECTION AND ERROR CORRECTION:

In the case of the error detection and correction codes described above, how an increase in the number of redundant bits added to message bits can enhance the capability of the code to detect and correct errors. If we have a sufficient number of redundant bits, and if these bits can be arranged such that different error bits produce different error results, then it should be possible not only to detect the error bit but also to identify its location. Actually, the addition of bits which are redundant alters the ‘distance’ Code parameter, which we know as the Hamming distance. Now we need to know what is hamming distance, it is nothing but the difference in number of bits between two code words which we are checking. We can explain it with an example,like the addition of single-bit parity results in a code with a Hamming distance of at least and the smallest Hamming distance in the case of a threefold repetition code would be hamming noticed that an increase in distance enhanced the code’s ability to detect and correct errors which is highly desirable. Therefore Hamming's code was an attempt to increase the Hamming distance and at the same time to have as high information at a throughput rate as possible. The algorithm for writing the generalized Hamming code is as follows:

  1. The generalized form of code is P1P2D1P3D2D3D4P4D5D6D7D8D9D10D11P5, where P and D respectively represent parity and data bits.
  2. We can see from the generalized form of the code that all bit positions that are powers of 2 (positions 1, 2, 4, 8, 16) are used as parity bits.
  3. All other bit positions (positions 3, 5, 6, 7, 9, 10, 11) are used to encode data.
  4. A group of bits from the data bits in the code word is allotted to each parity bit, and the value of the parity bit which is 0 or 1 is used to give it certain parity to make the operation smooth.
  5. Groups are formed by first checking N − 1 bits and then alternately skipping and checking N bits
    following the parity bit. Here, N is the position of the parity bit; 1 for P1, 2 for P2, 4 for P3, 8 for P and so on. For example, for the generalized form of code given above, various groups of bits formed with different parity bits would be P1D1D2D4D5, P2D1D3D4D6D7, P3D2D3D4D8D9, P4D5D6D7D8D D10D11 and so on. To illustrate the formation of groups further, let us examine the group corresponding to parity bit P3. Now, the position of P3 is at number 4. In order to form the group, we check the first three bits (N − 1 = 3) and then follow it up by alternately skipping and checking four bits (N = 4). We have discussed a lot about the Hamming codes and now we can conclude that these codes are capable of correcting single-bit errors on messages of any length. Although this code can detect two-bit errors, we are unable to get the error locations. The number of parity bits required to be transmitted along with the message, however, depends upon the message length, as shown above. The number of parity bits required to encode message bits is the smallest integer that satisfies the condition (2n^ – n)>m.