Contents
Chapter 1 · HardwarePractice

LEARN WITH HARU

Video Lesson တွေက Haru အတန်းသားတွေအတွက်ပါ

Haru ရဲ့ ITPEC FE Full Course မှာ ယခု သင်ခန်းစာတွေကို တစ်ခုချင်း တစ်ကြောင်းချင်း အသေးစိတ်ရှင််ရှင်းပြထားပါတယ်

အခြေခံ မရှိတဲ့ ကျောင်းသားများစွာဟာလည်း ဒီ Course နဲ့ ပဲ အောင်မြင်ကုန်ကြပါပြီ

အတန်းမအပ်သေးပဲ Haru ဆီမှာ အစမ်းသင်ကြည့်ချင်ပါသလား?

သင်တန်းသားတွေရဲ့ စကားသံများ

သင်တန်းသားတွေရဲ့ စကားသံများ

Highlighted text? Practice this concept. Highlighted passages and figures open related questions.

Practice related questions (60)Progress & bookmarks

p. 20

2 Data Representation in Computers

In order to make a computer work, it is necessary to store a program with a processing sequence and data to be processed inside the computer in advance. This section describes the methods of recording (representing) information inside computers.

2 - 1 Data Representation

(1) Unit of representation

Inside computers, data is recorded as electrical signals. Electric signals can basically represent only two states.

Two electrical states: current flowing or not, and high or low voltage, connected by two-way arrows
p. 20 · Enlarge

0 and 1 are linked to these two states, and they are recorded and saved as data inside computers. In other words, data recorded by computers is represented with 0 or 1. The minimum unit that represents this 0 or 1 is called a bit. Various meanings are formed by combining 0 and 1 represented by this bit, and they are recorded as data. At this time, one unit formed by collecting 8 bits is called a byte.

Figure 1-4 Bit and byte
p. 20

Moreover, there is a unit called word, which is formed by collecting more bits than in a byte. Word is the unit of processing inside computers, and there are 16 bits, 32 bits, 64 bits, etc. according to the model of computer used. Needless to say that if more bits can be processed at a time, then more information can be processed in a certain time. Therefore, the higher the number of bits in one word, the higher the processing speed of the computer. In most present-day computers, 1 word is 32 bits or 64 bits.

p. 21

(2) Information amount

There are two types (0, 1) of information that can be represented with 1 bit, and the number of bit combinations is referred to as the information amount. The information amount that can be represented with 2 bits is of 4 types (00, 01, 10, 11), the information amount that can be represented with 3 bits is of 8 types (000, 001, 010, 011, 100, 101, 110, 111), ... and so on. · 3 questions

Figure1-5 Number of bits and information amount
p. 21

As shown in Figure 1-5, branches increase with the increase of every one bit used, and the information amount that can be represented keeps on doubling. In other words, the information amount that can be represented with n bits is of 2n types (2n shows the power of 2, and means multiplying 2 by itself n times). Using this concept, a summary of the information amount that can be represented with byte and word (16 bits) is given below.

Information amount: n bits, one byte, and a 16-bit word, with the original powers and bit patterns
p. 21 · Enlarge

p. 22

Information theory: occurrence probability and information amount in the original complete callout
p. 22 · Enlarge

(3) Prefix

When data is handled, rather large numbers are handled as they are. However, it is very difficult to handle very large numbers or very small numbers without modification. Therefore, they are represented in combination with a prefix (auxiliary unit) representing a certain value.

For example, even if a nurse holding a newborn baby says “He is a healthy baby boy of 3,000g,” no one would say “I lately got a little fat and became 75,000g.” Normally, one would say “75 kg.” This “k” is the prefix. “k” is a prefix that means the value “103”, and it can

Original equation / mathematical notation
p. 22

The readings and values of major prefixes are summarized in the table below.

Large-number prefixes: kilo, mega, giga, tera and peta, with decimal and binary powers
p. 22 · Enlarge
Decimal magnitude prefixes · 1 practice questions

p. 23

Small-number prefixes: milli, micro, nano and pico, with their decimal powers
p. 23 · Enlarge

Here, for prefixes that represent large numbers, binary values are also shown in the table. This is because inside computers, for representing information in binary form by using two numbers of 0 and 1, prefixes are also represented in binary form when numbers related to computers are represented (details of binary numbers are explained later). For examples, data like “1k calorie” is not related to computers. Therefore, it means

Original equation / mathematical notation
p. 23

On other hand, data like “1k byte” is related to computers, and therefore it means

Original equation / mathematical notation
p. 23

However, it is almost equally related to “103≈210, 106≒220, ...”, and therefore it is often treated as 1k byte = 1,000 bytes these days. Memorizing this relation helps when arithmetic calculation problems are solved.

2 - 2 Radix and Radix Conversion

Decimal numbers that we normally use are numbers that are obtained by raising each digit to the power of 10 by using ten numbers from 0 through 9.

Decimal place-value expansion of 362.9, including the original base notation and explanation
p. 23 · Enlarge

Here, the weight (10) of the decimal digit is called radix, and numbers represented with radix n are referred to as n-adic numbers. n-adic numbers are represented by using n numbers from 0 through (n−1) that are carried over when n is reached.

(1) Binary numbers

Binary numbers are represented by using two numbers 0 and 1 that are carried over when 2 is reached. The smallest unit of information handled inside computers is a bit, and only two numbers of 0 and 1 can be used. Therefore, computers use binary numbers that represent numerical values

p. 24

with two numbers, 0 and 1.

Binary place-value expansion of 101.1 into decimal 5.5
p. 24 · Enlarge

Decimal numbers and their corresponding binary numbers are as shown below. Binary numbers can use only two numbers of 0 and 1 for one digit. Therefore, the number of digits quickly becomes large, compared with decimal numbers.

Figure 1-6 Decimal numbers and corresponding binary numbers
p. 24

(2) Octal numbers

Octal numbers are numerical values that are represented by using eight numbers from 0 through 7 and that are carried over when 8 is reached.

Octal place-value expansion of 317.5 into decimal 207.625
p. 24 · Enlarge
Figure 1-7 Decimal numbers and corresponding octal numbers
p. 24

(3) Hexadecimal numbers

Hexadecimal numbers are numerical values that are represented by using sixteen numbers from 0 through 9, and A(10), B(11), C(12), D(13), E(14), and F(15) and that are carried over when 16 is reached.

Hexadecimal place-value expansion of 1A6.E into decimal 422.875
p. 24 · Enlarge

p. 25

Figure 1-8 Decimal numbers and corresponding hexadecimal numbers
p. 25

(4) Relation between binary numbers, octal numbers, and hexadecimal numbers

Binary numbers have an extremely large number of digits compared with decimal numbers. Although computers can handle binary numbers without problems, it is very difficult for a human being to understand when the internal status of computers is concerned. Therefore, octal numbers and hexadecimal numbers are used so that people can understand more easily.

Original equation / mathematical notation
p. 25

information of 3 digits of binary numbers corresponds to 1 digit of octal numbers.

Binary-to-octal grouping: aligned groups of three bits, arrows, padding zeros and the resulting octal digits
p. 25 · Enlarge

Hexadecimal numbers use the power of 16(= 24) as the weight of each digit, and therefore the information of 4 digits of binary numbers corresponds to 1 digit of hexadecimal numbers.

Binary-to-hexadecimal grouping: aligned groups of four bits, arrows, padding zeros and the hexadecimal result
p. 25 · Enlarge

p. 26

(5) Radix conversion

Radix conversion · 32 questions means changing the radix of a numerical value. It is also radix conversion to convert a binary number (radix 2) into an octal number (radix 8) or a hexadecimal number (radix 16). When radix has a constant (power) relation as in the case of binary numbers, octal numbers, and hexadecimal numbers, radix conversion can be done by consolidating multiple digits. However, when radix does not have a constant (power) relation as in the case of binary numbers and decimal numbers, it is necessary to convert through computation.

  • 1) Radix conversion from a binary number into a decimal number Radix conversion from a binary number to a decimal number can be performed by adding the weight of each digit that is 1 in the binary number. (This is the same as adding the results that are obtained by multiplying the weight of each digit with the number (0 or 1) of each digit.)
Worked binary-to-decimal conversion of 1001101.101, with every digit aligned to its power and contribution
p. 26 · Enlarge
  • 2) Radix conversion from a decimal number into a binary number

Radix conversion from a decimal number into a binary number is performed separately for the integer part and the fractional part. The integer part can be converted by repeatedly dividing by 2 until the quotient becomes 0, and then arranging the remainder of calculation results in sequence from the back. A fractional part can be converted by continuously multiplying by 2 until the fractional part in calculation results becomes 0, and then arranging the integer part of each calculation result in sequence from the front.

p. 27

Worked decimal-to-binary conversion of 77.625, including both division and multiplication columns and reading-order arrows
p. 27 · Enlarge

A summary of radix conversion between decimal numbers and n-adic numbers is provided below.

Original radix-conversion procedures for integer and fractional parts, kept together in their complete box
p. 27 · Enlarge

For example, below is an example of radix conversion of the decimal number (67.6875)10 into an octal number.

Worked decimal-to-octal conversion of 67.6875, with division and multiplication columns and reading-order arrows
p. 27 · Enlarge

However, when the radix conversion from decimal to octal or hexadecimal is performed, it may be easier to convert from decimal to binary, and then convert the result into octal or hexadecimal.

p. 28

Decimal, binary and octal representations of 67.6875 with the aligned three-bit groups
p. 28 · Enlarge
Recurring binary fractions: complete explanation and repeated multiplication loop for decimal 0.2
p. 28 · Enlarge

2 - 3 Representation Form of Data

All data is represented with 0 or 1 inside computers. This representation form can be classified as follows:

Figure 1-9 Representation Form of data
p. 28

p. 29

2-3-1 Character Data

Inside computers, character data is represented with combinations of 0 and 1. In computers during the early stage of their development, 1 character was linked to a bit pattern of 8 bits (1 byte). Moreover, bit patterns linked to characters were referred to as character codes, with the six main character codes as described below. When data between computers is exchanged by using different character codes, character corruption (garbled characters) may occur where characters that are different from the original data are displayed.

(1) ASCII code

ASCII code is the character code defined by ANSI (American National Standards Institute) in 1962. It is composed of 8 bits, which include code bits (7 bits) that represent an alphabetic character or a number, and a parity bit (1 bit) that detects an error. Although it is used in PCs, it does not have any definitions concerning Japanese characters (e.g., kanji, kana). · 1 question

(2) ISO code

ISO code is a 7-bit character code defined by the standardization agency ISO (International Organization for Standardization) on the basis of ASCII code in 1967. This character code forms the basis of character codes used in different countries all over the world.

(3) JIS code

JIS code is a character code that is deliberated by JISC (Japanese Industrial Standards Committee) on the basis of the Industrial Standardization Act for representing Japanese-specific characters based on the ISO code and is defined as JIS (Japanese Industrial Standards).

  • 1) JIS 7-bit codes / JIS 8-bit codes (JIS X 0201) This character code can represent half-width katakana characters. Figure 1-10 shows the

table of JIS 8-bit codes for reference. Here is how to use the table. Firstly, search in the table for the character to be represented with the code. Secondly, arrange columns (higher 4 bits) and rows (lower 4 bits) from top to bottom and left to right respectively. The arranged numbers form the character code of that character.

p. 30

JIS character-code lookup for J, I and S: character, table position, binary code and hexadecimal code in aligned columns
p. 30 · Enlarge
Figure 1-10 JIS 8-bit codes (JIS X 0201)
p. 30
  • 2) JIS kanji code (JIS X 0208) This is a character code for representing 1 hiragana or kanji character with 2 bytes (16 bits).
  • 3) Shift JIS code This code system is formed by expanding JIS kanji code, and it is a character code that enables mixing of 1-byte characters and 2-byte characters without using a special switching code.

(4) EBCDIC (Extended Binary Coded Decimal Interchange Code)

EBCDIC is an 8-bit character code developed by the IBM Corporation of the United States. This code was originally developed by IBM for its own computers. However, 3rd generation (1960s) computers were mostly IBM computers, and therefore this code became industry standard (de facto standard) in the area of large computers.

p. 31

(5) Unicode

Unicode is the character code that was developed and proposed by U.S.-based companies like Apple, IBM, and Microsoft as a 2-byte universal uniform code for smooth exchange of computer data. It supports characters of several countries such as alphabets, kanji and hiragana/katakana, Hangul characters, and Arabic letters. This was standardized by ISO as an international standard, and at present, UCS-2 (2 bytes) and UCS-4 (4 bytes) are defined.

(6) EUC (Extended Unix Code)

EUC (Extended Unix Code) is the character code that was defined by the AT&T Corporation for internationalization support of UNIX (an OS (Operating System), which is a software program for controlling computers). An alphanumeric character is represented with 1 byte, and a kanji or kana character is represented with 2 bytes. In this case, kanji characters are codes where the hexadecimal number “80” is added to JIS kanji code. Therefore, in the kanji part, the value of the most significant bit is “1”, and it is possible to differentiate single byte alphanumeric characters and kanji characters.

Moreover, although it is not a character code, zoned decimal numbers are also classified as a code that represents character data (Details of zoned decimal numbers are explained in the next sub-subsection entitled “Numeric data”).

2-3-2 Numeric Data

In broad terms, there are two methods for numeric representation inside computers. The first method is to represent numerical values with binary numbers, which is suitable for performing calculations inside computers. However, binary numbers are not easy for humans to use, and therefore there exits another method where decimal numbers are adopted to facilitate understanding for humans.

(1) Decimal notation

This is a numeric representation method of introducing the way of thinking about decimal numbers that are easy-to-understand for humans. In specific terms, BCD code (Binary-Coded Decimal code) where each digit of a decimal number is converted into a 4-bit binary number is used.

p. 32

BCD representation of decimal 2741: digits 2, 7, 4 and 1 align above four downward arrows and the groups 0010, 0111, 0100 and 0001. Complete original example box.
p. 32 · Enlarge
  • 1) Zoned decimal number This is a format that represents 1 digit of a decimal number with 1 byte. A binary-coded decimal code is stored in the lower 4 bits of 1 byte corresponding to each digit, while zoned bits are stored in the higher 4 bits. However, a sign bit indicating a sign is stored in the higher 4 bits of the lowest digit. Zoned bits and sign bits differ depending on the character code used in computers. When EBCDIC is used, “1111 (F)” is stored in the zoned bit, while “1100 (C)” is stored as a sign bit if it is positive (+) and “1101 (D)” is stored as a sign bit if it is negative (−). On the other hand, when ASCII code or JIS code is used, “0011 (3)” is stored in the zoned bit. In most of the cases, the sign bit uses the same value as in the case of EBCDIC (it differs by manufacturer because there are no uniform definitions).
Zoned-decimal representation of positive 672 and negative 1905, including all zone bits, sign bits, digit labels and the example explanation
p. 32 · Enlarge
  • 2) Packed decimal number This is a format that represents 2 digits of a decimal number with 1 byte. Each digit of a decimal number is represented with a binary-coded decimal code and this is the same as the zoned decimal number, however, it differs because the sign is shown with the lowest 4 bits, and when it falls short of a byte unit, 0 is inserted to make it a byte unit.

p. 33

Packed-decimal representation of positive 672 and negative 1905, including digit groups, sign nibbles and the example explanation
p. 33 · Enlarge
Packed decimal and sign nibble · 1 practice questions

If we compare zoned decimal numbers and packed decimal numbers, by packing after the omission of the zoned bits (higher 4 bits) of zoned decimal numbers, the packed decimal numbers can represent more information (digits) with fewer bytes. Moreover, it is called unpacking to represent packed decimal numbers by using zoned decimal numbers, and therefore the zoned decimal numbers are also referred to as unpacked decimal numbers. While zoned decimal numbers cannot be used in calculations, packed decimal numbers can be used in calculations. However, when decimal numbers from an input unit are entered, or when decimal numbers are sent to an output unit, it is preferable to use zoned decimal numbers because the unit (1-digit numerical value) of input/output and the unit (1 byte) of information correspond to each other. Therefore, conversion between zoned decimal numbers and packed decimal numbers is performed inside computers.

Figure1-11 Conversion between zoned decimal numbers and packed decimal numbers inside computers
p. 33

(2) Binary notation

Forms for representing numerical values as binary numbers that are easy to handle inside computers include fixed point numbers where the number of digits of integer part and fractional part are decided in advance, and floating point numbers where the position of radix point is changed according to the numerical value to be represented.

p. 34

  • 1) Fixed point numbers In this form of representation, numerical values are handled by fixing the radix point at a specific position. Generally, it is mostly used for handling integer numbers by fixing the position of the radix point in the least significant bit.
Fixed-point storage positions and the aligned radix-point indicator
p. 34 · Enlarge

In this form of representation, after numerical values are converted into binary numbers, they are used without modification according to the position of the radix point.

Representation of decimal 89 as an eight-bit fixed-point value: full example and register layout
p. 34 · Enlarge

In fixed point numbers, methods of representing negative numbers (representation forms of negative numbers) are important. The two main methods are described below. · 9 questions

A: Signed absolute value notation In this method, the most significant 1 bit is used as a sign bit, and 0 is stored in it if the numerical value is positive, while 1 is stored in it if the numerical value is negative. In the remaining bits, the binary bit string is stored as it is.

Signed-magnitude representation of positive and negative 89, including the highlighted sign bits and both aligned register rows
p. 34 · Enlarge

B: Complement notation In this method, when a negative number is represented, the complement of the positive number is used.

p. 35

Complements: complete callout with the decimal 614 and binary 01101101 subtraction examples, reference values and results
p. 35 · Enlarge
Twos-complement representation of positive and negative 89, including the subtraction and both signed register layouts
p. 35 · Enlarge

Generally, 2’s complement notation is often used in fixed point numbers for the following reasons.

p. 36

1. Subtraction can be substituted for addition. When signed absolute values are used, addition or subtraction must be appropriately selected according to the first bit of each numerical value to be calculated. However, when 2’s complement is used, calculation can be performed without any selection. By using this, subtraction can be represented with addition.

Worked subtraction of 10 from 15 using twos complement: both stages, carries, register rows and discarded carry annotation
p. 36 · Enlarge

By using this concept, a feature for subtraction is not required if computer has the feature for addition and the feature for calculating complement. Moreover, if multiplication is done with iterations of addition, and division is done with iterations of subtractions, four basic arithmetic operations (addition, subtraction, multiplication, division) can be done with addition only.

2. A wide range of numerical values can be represented. When signed absolute values are used, two types of 0s, namely (+0) and (−0), occur. However, there is only one type of 0 when 2’s complement is used. Since the information amount of identical numbers of bits is the same, 2’s complement enables the representation of a wider range of numerical values.

p. 37

Eight-bit signed-magnitude and twos-complement ranges compared side by side, preserving positive and negative zero and both negative limits
p. 37 · Enlarge
Range of signed values representable by n bits in twos-complement notation, with the original superscripts
p. 37 · Enlarge
  • 2) Floating point numbers · 6 questions If the number of bits that can be used for representing numerical value is decided, the range of numerical values that can be represented with fixed point numbers is limited. Therefore, when a very large numerical value is handled, the number of bits should also be increased accordingly. However, in reality, the number of bits used for recording data cannot be increased infinitely. Therefore, floating point numbers are used to represent extremely large numbers or extremely small numbers below the radix point.

Before the explanation of the representation of numbers inside computers, the mechanism of floating point numbers is explained by using decimal numbers. The case that there is the numerical value below is considered here.

+456,000,000,000

For the ease of explanation, when 1 unit is used for recording a sign or one number, 13 units are required for recording this numerical value as it is.

Thirteen storage positions for the sign and decimal digits of 456000000000
p. 37 · Enlarge

Here, if we convert the numerical value and then record only required information in the following manner, we can represent this numerical value with a total of 6 units.

Scientific-notation conversion of 456000000000 to 0.456 times ten to the twelfth power
p. 37 · Enlarge

p. 38

Floating-point sign, fraction and exponent aligned with their stored decimal digits and explanatory labels
p. 38 · Enlarge

This is the concept of floating point numbers. Using this concept, from extremely large numerical values to extremely small numerical values can be represented with the same number of digits. “10” in power of 10 used in representing exponent is called radix. Since a decimal number was used in this explanation, “10” was used as it is easy to understand in terms of moving the radix point. However, since binary numbers are used in computers, either “2” or “16” is used.

Original basic floating-point formula, preserving sign, fraction, radix and superscript exponent
p. 38 · Enlarge

In reality, the form of representation of floating point numbers used inside computers differs depending on the model. Here, we explain the single-precision floating point number (32-bit format) and double-precision floating point number (64-bit format) standardized as IEEE 754 format. A double-precision floating point number can handle a wider range of numerical values with higher precision.

Single-precision 32-bit floating-point layout: sign 1 bit, exponent 8 bits and fraction 23 bits, with the complete source heading
p. 38 · Enlarge
Double-precision 64-bit floating-point layout: sign 1 bit, exponent 11 bits and fraction 52 bits, with the complete source heading
p. 38 · Enlarge

There are several forms of representation of information in each part of the floating point number format. Main forms of representation of each part are as follows:

A: Sign (S)

p. 39

This is used for representing the sign of a numerical value. It is 0 for positive values, and 1 for negative values.

B: Exponent (E) This is used for representing exponent with respect to radix. The two main representation methods below are used.

  • • 2’s complement: In this method, exponent is recorded as a binary number, and 2’s complement is used if it is negative (−).
  • • Excess method: This method records a value (i.e., biased value) that is obtained by adding a certain value to the exponent. The value (i.e., bias value) to be added is decided according to the number of bits of exponent. Below is an example of the excess method used with single-precision floating point numbers.
Exponent bias comparison table: Excess 127 for IEEE 754 and Excess 64 for IBM, including all grouped headers
p. 39 · Enlarge

C: Fraction (mantissa) (M) This is used for representing a numerical value after the radix point. In order to represent the part after the radix point, it is common to perform normalization. In this case, the integer part is either set to 0 or 1 (storing after the omission of 1 from the integer part).

  • • When the integer part is set to 0: 0.101101 → Store “101101” in fraction (mantissa)
  • • When the integer part is set to 1: 1.011010 → Store “011010” in fraction (mantissa)
Normalization example: first source-page portion, with the seven stored fraction digits and its complete explanation
p. 39 · Enlarge

p. 40

Normalization example: continuation on the next source page, with normalized form and aligned stored digits
p. 40 · Enlarge
Complete worked IEEE 754 single-precision encoding of decimal 1234.625: conversion, normalization, biased exponent and final 32-bit layout
p. 40 · Enlarge

p. 41

2-3-3 Error

Error refers to the difference between the actual value and the value represented inside the computer. When numerical values inside the computer are handled, we must pay attention to error. For example, when (0.1)10 is converted into a binary number, it is represented as follows: · 3 questions

Original equation / mathematical notation
p. 41

The conversion result becomes a recurring fraction where “0011” is repeated an infinite number of times. However, since there is a limit for the number of bits that can be used for representing numerical values inside computers, the only option for storing in fraction (mantissa) is to store after the loop is cut in the middle. If it is 8 bits, only up to (0.00011001)2 can be stored. When this binary number is converted into a decimal number, (0.09765625)10 is obtained. In other words, this is different from the original numerical value (0.1)10 by only (0.00234375)10. This is error.

(1) Rounding error

Rounding error occurs when the part smaller than the least digit is rounded off, rounded up, or rounded down in order to represent the real number with the effective number of digits in the computer. When a decimal number is converted into a binary number, this kind of error occurs to represent the resulting binary number with the effective number of digits. As a measure against rounding error, there are methods such as minimizing the value of error as much as possible by changing single precision (32 bits) into double precision (64 bits).

(2) Loss of trailing digits

Loss of trailing digits is the error that occurs when an extremely small value is ignored at the time of computing two values: one absolute value is extremely large and the other is extremely small.

Loss of trailing digits: complete floating-point addition with aligned values, underlining and the ignored-value annotation
p. 41 · Enlarge

p. 42

In order to minimize loss of trailing digits, when multiple numerical values are added with floating point radix numbers, it is necessary to take steps such as arranging all data in the ascending order of absolute value, and adding them in sequence from the top (smaller value).

(3) Cancellation of significant digit

Cancellation of significant digit is the error that occurs because of decline in the number of significant digits that can be trusted as numerical values when calculation is performed between almost equal numerical values. · 1 question

Cancellation of significant digits: complete binary subtraction example, aligned operands and unreliable-digit annotation
p. 42 · Enlarge

(4) Overflow, underflow

Inside a computer, the range of numerical values that can be represented is already decided, because the limited number of bits is used for representing them. Flow is the error that occurs when the calculation results exceed this range of representation. When the calculation results exceed the maximum value of range of representation, it is referred to as overflow, and when it exceeds the minimum value, it is referred to as underflow. When it is simply referred to as “flow,” it mostly means overflow.

Overflow and underflow: minimum and maximum values, representable range, baseline and directional labels together
p. 42 · Enlarge

Moreover, the following two indexes are used as the concept of evaluating these errors (whether precision is high or low).

  • • Absolute error: This is an index that evaluates on the basis of how large the actual error is.
Absolute error: the complete original boxed formula with absolute-value bars
p. 42 · Enlarge

p. 43

  • • Relative error: This is an index that evaluates on the basis of the proportion (ratio) of error with respect to true value.
Relative error: the complete original boxed fraction, including numerator, denominator and absolute-value bars
p. 43 · Enlarge

2-3-4 Shift Operation

Shift operation is the operation of shifting the position of bit to left or right. Shift operation is used in computation of numerical values, and in changing the position of bits. · 1 question

(1) Arithmetic shift

Arithmetic shift · 9 questions is the shift operation used when numerical values are computed. It is mainly used in fixed point numbers that represent negative values in 2’s complement.

[Rules of arithmetic shift]

  • • Do not shift the sign bit.
  • • Truncate extra bits that are shifted out as a result of the shift.
  • • Store the following bit in the empty bit position that is created as a result of the shift. In the case of left shift: 0 In the case of right shift: Same as the sign bit
Arithmetic left shift by two bits: complete example with source and result registers, arrows, discarded bits and inserted zeros
p. 43 · Enlarge

Binary numbers have weight of power of 2 in each digit. Therefore, even for the same numeral 1, 1 as the second digit and 1 as the third digit have different meanings.

Original equation / mathematical notation
p. 43

p. 44

Because of this, computation rules of arithmetic shift can be summarized as follows:

Computation rules of arithmetic shifts, including powers of two and the complete original callout
p. 44 · Enlarge

(2) Logical shift

Logical shift is the shift operation used when the position of bits are changed. Its main difference from the arithmetic shift is that it does not treat the sign bit in a special manner.

Logical-shift rules: complete original callout
p. 44 · Enlarge
Comparison of arithmetic and logical right shifts by two bits: both register diagrams, arrows, sign extension, inserted zeros and results
p. 44 · Enlarge
Logical right shift with inserted zeros · 1 practice questions

p. 45

Rotation shift (circular shift) is a type of logical shift. In rotation shift, the bits shifted out are circulated to the empty positions.

Circular right shift by two bits: complete example box with the returning-bit arrows and explanation
p. 45 · Enlarge

Original chapter exercises

Original chapter exercises →

New FE Textbook Vol.1 · IT Fundamentals · First Edition, April 2015