0% found this document useful (0 votes)
23 views153 pages

Book 3

The document provides a comprehensive overview of data representation in computers, covering topics such as binary digits, number systems, and data processing methods. It explains how digital computers convert data into machine-readable binary form and details various data representation techniques including electronic circuits, magnetic media, and optical media. Additionally, it discusses programming principles, system development methodologies, and database design, emphasizing the importance of data integrity and processing accuracy.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
23 views153 pages

Book 3

The document provides a comprehensive overview of data representation in computers, covering topics such as binary digits, number systems, and data processing methods. It explains how digital computers convert data into machine-readable binary form and details various data representation techniques including electronic circuits, magnetic media, and optical media. Additionally, it discusses programming principles, system development methodologies, and database design, emphasizing the importance of data integrity and processing accuracy.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
REPUBLIC OF RENN Property of the Government of Kenya NOT FOR SALE Contents 1. Data representation in a computer... 4.1 Introduction... 1.2 Basic concepts 1.3 Data representation in digital computers Data representation in electronic circuits Data representation on magnetic med Data representation on optical medi Reason for use of binary digits. Definition of bits, bytes, nibble and word 1.4 Types of data representation in computers. Numiber systems... 1.5 Conversion between numbers systems. Converting binary numbers to decimal form... Converting decimal numbers to binary form.. Converting a binary fraction to decimal form. Converting a decimal fraction to binary form. Converting octal numbers to decimal form. Converting octal numbers to binary form Converting binary numbers to hexadecimal form... Converting hexadecimal numbers to decimal form Converting hexadecimal numbers into binary numbe 1.6 Data representation using symbolic codes... Binary Coded Decimal (BCD)... Extended Binary Coded Decimal Interchange Code .. ‘American Standard Code for Information Interchange... 1.7 Binary arithmetic operations... Representation of signed binary numbers... Binary addition Binary subtraction... Subtraction using one’s complements. Subtraction using two's complements... Revision Exercise 1...... SOAR A RHEE NAO 2, Data procesSiN nner 2.1 Introduction ... 2.2 Data processing cycle Data collection .. Data input ..... Data processing. Data output 2.3 Errors in data processing... ‘Transcription errors. Computational errors. Algorithm or logical errors 2.4 Data integrity ... Accuracy Timeliness ......... Relevance 2.5 Data processing methods Manual data processing... Mechanical data processing Electronic data processing. 2.6 Computer files..... Elements of a computer file .. Logical and physical files. 2.7 Types of computer processing files... Master file .. Transaction (movement) file .. Reference file Backup file 39 Report file. 39 Son file... — 39 2.8 File organisation methods... ‘Sequential file organisation 40 Random file organisation Serial file organisation... 40 Indexed-sequential file organisation ... at 2.9 Data processing modes.. a On-line processing wc a Real-time processing, 42 Distributed data processing ie Time-sharin 2 Batch processing... a2 Multiprocessing. 7 z - & Multiprogramming, a Interactive processing... a3 Revision Exercise 2 44 3. Elementary programming principles .. - 3.1 Introduction .. =. Ae 3.2 Introduction to computer programming .. » 46 3.3 Description of programming terms... - 46 46 46 46 _ 47 47 49 57 58 59 59 60 62 68 63 64 64 66 67 Source code Object code . ‘Translators ......... 3.4 Levels of programming languages. Low-level languages High-level languages 3.5 Program development Problem recognition... Problem definition, Program design .. Program coding Program testing and debugging... Program implementation. 3.6 Program documentation.. 3.7 Designing program algorithms Pseudocode.. ie Designing flowcharts. Comparing pseudocode and flowchart... a Not for sale 3.8 Program control structures - 68 Sequence control structure. a Selection control structure @ Looping control structure... B 3.9 Designing complex algorithms.. Revision Exercise 3.... 4. System development. - 86 4.1 Introduction ... 86 Description of systems... 86 Soft systems Hard systems.. ‘System characteristics. 4.3 Information systems... Reasons for developing information systems..... Roles of system analyst. Project management... 4.4 System development methodologies. Traditional approaches ...0... 90 Structured system development methodologies. OL Rapid Application Development (RAD) ... 95 4.5 System development process... 96 Problem recognitior 7 Problem definition. 98 Information gathering ... 98 Preparing data collection report... Requirements specification Designing system flowcharts System construction... System testing System implementation.. System changeover strategies... System maintenance and review .. 4.6 System documentation... Fact finding report Requirement speci System flowchart. ” 2 ee cel System testing report... ase design report System output reports..... User manual..... 13 Revision Exercise 4, 5, Appendix |: Data application... A1.1 Introduction to database design Defining attributes A1.2 Creating database in Microsoft Acces: Table Design... . Setting primary and foreign ee. A1.3 Database automation... Creating Macros.. Using Visual Basic for Application .. A1.4 Enforcing database securl A1.5 Database startup... A1.6 Conclusion... Appendix Il: VBA programming A2.1 Introduction ... A2.2 Macros and modules A2.3 Integrated development environment Menus and toolbar .. Project explorer «. Properties window . Code window Immediate window - A2.4 Creating and running VBA codes ....... A2.5 Variables, constants and data types Variables ..... Constants .. Data types 2.6 Operators and Expressions ..... Arithmetic expressions ... Comparison expressions Logical expressions Precedence rule ... A2.7 Program control structures Selection control structures. Looping control structures A2.8 Modules, functions and subroutines .. 137 Creating modules .. 137 Creating Subroutines .. Creating functions . 2.9 Automation of forms and reports ... 139 Form module-level events . 139 Form control-level events 141 Report module-level events .. 7. Appendix Ill Symbolic codes ..........sse.000- i A3.1 Coding schemes.. Binary Coded Decimal (BCD))..... Standard Binary Coded Decimal..... ASCII and EBCDIC Coding Schemes...... ‘DATA REPRESENTATION IN COMPUTERS Chapter 1.1 Introduction outline 1.2 Basic concepts 41.3 Data representation in digital computers 14 Types of data representation LS Conversion between number systems 1.6 Data representation using symbolic codes 1.7 Binary arithmetic operations 1.1 Introduction In Book 1 of this series, we learnt that computers are classified according to fiunctionality, physical sizeand purpose, We further classified computers according to functionality into analog, digital and hybrid, Digital computers process data that is in discrete (binary) form while analog. computers process data that is continuous (analog) in nature. In this chapter, we discuss in details how digital computers represent data using a sequence of binary digits (bits). 1.2 Basic concepts Indigital computers, the user input s first converted and transmitted as electrical pulses (signals) that can be represented by two distinct states ON and OFF. The ON state may be represented. by “I” and OFF state by a “0”. The sequence of ON’s and OFFs forms electrical signals that the computer can understand. Figure 1.1(a) shows a digital signal represented graphically as a square wave, while Figure 1.1(b) shows an analog signal represented asa continuous sine wave. a | (a) Representation of digital signal (@) Representation of analog signal Fig. 1.1: Digital and analog data representation Looking: atFigure 1.1 (2), you will observe thata digital signal rises suddenly toa peak amplitude ‘of +1, holds for sometime then suddenly drops to -I level. On the other hand an analog signal ses to +1 and falls to 1 in a continuous version (Figure 1.1 (b) Although the two graphs ook different in their a notice that they repeat themselves at equal time intervals letra signals or waveforms of this nature aresaido beperiodic. Generally, periodic wave representing a signal can be described using the following parameters: 1. Amplitude (A) 2. Frequency () 3. Periodic time (T) Amplitude (4): Thisis the: maximum displacement that the waveform of an electrical signal can attain, For example, the amplitude of the electrical signals in Figure 1.1(a) and (b)is 1 (one) Frequency (fi: Tisis the number ofeycles(360°ymade by the signal in one second. Itis measured in units called hertz (Hz). IE1z is equivalent to 1 cycle/second. eioaie me (1): This isthe time taken by a signal to complete one eyele, Period time, 7 i given by the formula T = +, where fis the frequency of the wave. ‘When a digital signals to be transmitted over analog telephone cables, it has o be converted to analog form. This is done by connecting a device called a modem tothe digital ompuer. This process of converting a digital signal to analog signal is known as modulation. On the receiving end, the incoming analog signal is converted back to digital form in a process known ve vlemodalation; hence the acronym modet. Figur 1.2 shows how datas transmitted via the telephone line froma sending computer to a receiving computer. internet Fig. 1.2: Sending data via a telecommunication network 4.3 Data representation In digital computers Data and instructions cannot be entered and processed directly into computers using human language. Any type of data, be it numbers, letters, special symbols, sound or pictures must first be converted into machine readable from (binary form). For this reason, itis important to ‘understand how a computer together with its peripheral devices handle data in its electronic circuits, on magnetic media and in optical devices. This section explains how data is represented as binary digits (bits) in digital computers. 1.3.1 Data representation in electronic circuits es compone! Tahearahity, ba a8 the microprocessor are made up of millions of electronic (OFF) sinter a High voltage (ON) in these ciruits is interpreted as ‘I ‘while low eas ccireut Gon - 2 ‘0°. This concept can be compared to switching on and off of Reagent cea Eel ‘gue 1.3), When the sich closed, gue 13 (2) the high veri 3 0, le ba ee igh (1 state), On the other hand, when the switch is Egil computes ung tien reser 7h forms the basis for data representation se igs Sy io T t L_/, Batt swith en Eat closed open (@) Switch closed, bulb lights (©) Switch open, bulb goes off (T'state) (0' state) Fig, 1.3: Demonstrating the concept of binary digits using circuits 1.3.2 Data representation on magnetic media The presence ofa magnetic field in one direction on magnetic media is interpreted as ‘1’ while the field in the opposite direction is interpreted as ‘0°. Magnetism is mostly used on storage devices which are coated with special magnetic materials such as iron oxide. Data is written on the media by arranging the magnetic dipoles of some iron oxide particles to face in the same direction and others in the opposite direction. Figure 1.4 shows hiow data i recorded on the surface of a magnetic disk. Note that the dipole arrows on the track are arranged in groups facing opposite directions. Fig, 14: Data recording on the surface of a magnetie disk 133 Data ion on optical media inoptical media suchas CD-ROM, the presence of light {s interpreted as ‘I while its absence ig “0°. Optical devices use this technology to read or store dat interpreted as y 1 CD-ROM. Ifthe shiny surface is placed under a microscope, the surface is observed to han Oe Lancs as shown in Figure 1.5. As the disk rotates and the laser beam strikes a and, js reflected onto a photoelectric cell the reflected beam is interpreted as | bit. However, when the laser beam strikes a pit, the photoelectric cell receives only a weak reflection; interpreted as O bit. The sequence of bits read by the optical drive results in a pure digital playback of music or video. : Laser beam scattered once it Eater teams ee nee strikes a pit and registers 0 bit Fig |, 5: How data is recorded on CD-ROM using high precision laser beam 1.3.4 Reason for use of binary digits Manufacturing computers and other electronic devices that understand or process human languages is difficult due to the complexity of these natural languages. However, by using digital logic, itis easier to design and fabricate digital systems that take a proportion of natura language instructions. In such systems, data is encoded into binary form. Furthermore, digita devices are more reliable, small in size and power-efficient compared to analog devices. 1.3.5 Definition of bits, bytes, nibble and word In digital computers data, is represented using a series (stream) of bits that makes up a byte nibble or word. + Bit: Itisabinary digit which can either be 0 or 1. Itis the! = Byte: Itis a group of bits (often 8) used to represent achara basic unit of measuring memory size in computer. = Nibble: The term refers to half of a byte; usually a series of 4 bits. ‘basic unit of data in digital computers ter. A byte is considered as thi «Word Two or more bytes mi ; word, Theter numberof bits in each wont nee on The term sre loner is used as a measure of the ‘example a word can have a length of 16 bits, 32 bits, and Abit inary representati of 32 bits represent a 32-bit Wonk, representation of the four terms. Notice that the stream Fig 1.6, Representation of bit, byte and word Differentiate between analog and digit , Define he following ems, ma @ palin fine menor colisplerxs a UeNcy Me ranrer 4 Cycle F |B poodetine foc ce 4p Se to cure oe ca 3, Explain the roe ofa modem in conimtnton i 4. Using illustrations, explain how data is represented: (a) inelectronic circuits. &) onmagnetic media. © onCD-ROM. State the reasons for use of binary data in digital technology. Distinguish between: yte fo grup s he (@) Byte andmibble. — Mabbt vf ate hort 2 @ byte ~ eh reotte Tome sre mere bin \ (0) Word and word length. * Weed fo hrecare He nembr bitr bn goo weet 1.4 Types of data representation in computers Computers not only process numbers, letters and special symbols but also complex types of data ‘However these complex types of data take a lot of memory such as sound, pictures and videos. and processor time when represented in binary form. ‘This limitation necessitated the need to develop better ways of handling ongstreams of binary digi, Other number systems are used in computing to reduce these streams of binary into manageable form. This helps o improve the processing speed and memory usage. In this section, We disouss how data is represented using number systems and symbolic codes. kW LH /o8] 2019 Number systems ‘A number system can be defined as a set of symbols used to represent values derived from, common base or radix. As far as computers are concemed, number systems can be classifi. into four categories: 1, Decimal number system. 2. Binary number system. Octal number system. Hexadecimal number systems. _— ecimal number system term decimal is derived from a Latin prefix deci which means fen. Decimal number systen: ten digits ranging from 0-9. Because this system has ten digits, it is also called a base iber system ot denary number system. "A decimal number should always be written with a subscript 10 e.g. X,,. But since this is the 1 widely used number system in world, the subscript is usually understood and ignored in ftten work. However, when many number systems are considered together, the subscript ‘Be always be put so as to differentiate the number systems. The magnitude of a number is ~ evaluated using three parameters. 1, Absolute value. : Place value or positional value. 3. Base value. beThewbsolute value is the magnitude of a digit. For example, the digit 5 in 7458 has an absolute value of 5 according to its value in the number line as shown in the Figure 1.7. see BO? 0 dyad B48 4.57 6 Fig. 1.7: Absolute value - Creatas value of a digit in an number refers to the position of the digit in that number i.e. whether “tens”, “hundreds”, “thousands” etc for decimals number system as shown in Table 1.1 Table 1.1: Decimal numbers place value Thousands, 10°} Hundreds, 10? |_ Tens, 10'| Ones, 10° 7 4 5 8 The total value of a number is the sum of the place value of each digit making the number. For example, the total value of decimal digits in Table 1.1 can be worked out by as shown below: 7x 1000 = 7000 4x 100 400 Sxl0 = 50 Nyy =(7x 10) + - (4x LH) F (5 (8x 10 (Sx 104+ = (7x 1000) + 5 (x) + (4x 100) +(5x 10) + = 7000 +400+ s0+§ = 7458 &xl Total ‘The base value of a feing need The eral als known as the radix, is the type of a number systet {ois not equivalent to 100 a er depends on the radix, For example, the number 100 base Binary number system Binary number i Fe topics isa only two digits, and 0 to represent numbers Unlike decimal numbers Mia mati goup inpowers often, inbinay system, theplce valuesinetease by powersof re Biy es eit Consider binary number such as 1011. The right digit (least signi igt (LSD)) has a place value of | x 2° while the left gt (most nificant digit (MSD) basa place value of 1 x 2° as shown in Table 1.2, - - Table 1.2: Binary numbers places vale . Place values (2")| Eights2°=8 [| Fous2=4 | Twos?! Binary digit 1 0 ; Ones 2°= 1 No = (1x2) + Ox Z+(Lx W+(UX2) =(1x8)+ (0x4) +(x )+(1x1) No =lly Octal number system from 0 —7 to represent an octal number. The octal number system uses eight digits running The place value of ‘octal numbers go up in powers of eight from right to left as shown in Table 13. For example, to represent an octal number suchas 7245, place cach digit in its positional value as follows: Table 1.3: Octal numbers, place value Fan] = | s=8 7 2 4 Place values Ocial digit The decimal equivalent N,, of 7245, can be worked out as follows: Ny =O xB) FE Xx BH & BN+G x 89) 7x512 = 3584 2x64 = 128 = (7x 512)+ (2x 64) + (4x 8) +(5 x1 CxS OXG)HEKD+ED | Ae Ly = 3584+ 128 +3248 Bont Exot Ne Nyy =37490 Total = 3749 Hexadecimal number system ‘This is a number system with a radix of 16. Ituses sixteen digits ranging from 0-9 and letters ‘AF where A is‘equivalent to 10, B to 11, up to F which is equivalent to 15. Table 1,4: Octal and hexadecimal digits Base 10/0 | 1[ 2] 314 {5 [6] 718 | 9 |10}11 |12/ 13 |14| 15 Base 16/0 | 1| 2]}3}4 [5 |6 7/819 LA|BIC|D/E|F The place value of hexadecimal numbers goes up in powers of sixteen as shown in Table 1.5 Table 1.5: Hexadecimal numbers place values Blace value 16=256 16'=16 | 16°=1 Hexadecimal digit 9 4 ul Table 1.4 gives digits for base 10 and base 16. “A hexadecimal number is usually denoted using 16 as a subscript or capital letter H to the right of the number. For example, 94B can be written as 94B,,, or 94BH. ‘The decimal equivalent of 94B, , can be worked out as shown below. Ny =O x16) +4 x 16})+ (11 x 16°) 9x256 = 2304 = (9 x 256) + (4x 16) +(11 x 1) 4x16 = 64 Ny =2379, Tix ss 0 239 Reasons for using octal and hexadecimal number systems 1, Assingle octal or hexadecimal digit encodes more than one binary digit, This is automatic data compression, hence storage mediums can save on space. 2. Instead of transmitting long digits of 0’s and 1’s between devices, the data can be encoded as octal or hexadecimal to improve transmission efficiency. 4,5 Conversion between number systems So firr, we have looked at the fourty ic concepts eneral and limited yw ina gener’ Ce Way. In this section, we shall have a detailed look at how to convert numbers {fom one system to another es oF number systems and introduced their 1.5.1 Converting binary numbers (o decimal form ‘To convert a binary number to decimal number, we proceed }, First write the place values Starting from the right hand side. 2, Write each digit under its place value, 3, Multiply ea follows: h digit by its corresponding place value, Addl up the products. ‘The answer will be a decimal number e141 ' 101101, to a base 10 (or decimal) number. ‘solution Place each binary digit under its corresponding place value Place value | 2° 2 ele [a | 2 Binary digits |_1 0 1 1 0 1 Multiply each digit by its place value 32x1 = 32 Nyy =(1% 2) 4(0 x 24 (1 x29) ‘guét 0 (1 x 2)4 (0x2) +(1 x2) axi = 8 4xf 4 Ng =32+0+8+4+041 ea nie txt 44 i, NB: Remnember'o indicate the base subscript since itis the value that distinguishes the different number systems. Example 1.2 Convert 100100, into a base 10 number. Solution : L 2 a Place value BG [2 2 7 0 Binary digits 1 lo Ny a(t x 2)+(0 x 29402) au ; 4 (1 240 x 2)4 0x2) Ny =324+04+0+440+0 8x0 = 0 =36,, 4xl= 2x0= 0 1xo= +0 36 Ree a cacetid Convert the following base two numbers into denary (base 10) numbers. 1. 0101, 2 Ml, 3. 10101101110, 4. tout, 5. 1011001, 6. 111000111, 1.5.2 Converting decimal numbers to binary form Toconvert adecimal numberto binary, there are two possible methods, the long division method and the place value method. In long division method, the decimal number is continuously divided by 2. However, at each level of the division, the remainder which is either a | or 0 is written to the right of the quotient. Starting from bottom upwards, read the series of the remainder digits. The series of I’s and 0’s obtained represent the binary equivalent of the number. Example 1.3 Example 1.4 Using the long division method, convert 45,, | Using the long division method, convert into binary. 247,, into binary. Solution Solution 245 2| 247 2}22 R1 2/123 R14 alii RO 2[ér_Ri as Rt 2[ 30 R1 ae rt 2[45_ Ro at RO 2,7 RI [o ri 2[ 3 At 2], 1 RI Therefore, 45,,=101101, o R41 Since dividi merge ae mites, 1B 2dc0s | rae Age HDI temainder, convert a decimal numt it To iber to a binary numberusing place value method proceed as follows: ‘o see ‘elu infact of 2 up tothe vale immed lg real 0 place values up ee cy For example to convert 247, into binary, we write down the P ie. 512. Ifthe number bei Similarly to convert 258, write down the place values up 10 aaa bet being considered itself aftr of such as 64, 128, 256 etc., n Should be written up to the number itself. rert 2: it 2 Fa ton a te Pinar, tat fone tts shownin Table 1.6 Subtract the place value ra tbe nerd er being converted, If the difference is a positive number or a0, place a inary digit row. Ifthe difference is negative, place a zero. In Table 1.6, ; 0 isphoed in the binary digits row of the first column because 247 ~ 256 gives negative value, The number 247 is then carried forward to the next lower place value ie. 128. Table 1.6: Place value Method 1 Place value wes a 2 | 25] 2 {2° |2? | 2! 2" Difference 247 — 256 | 247-128 Binary digit 0 x Subtract 128 from 247. Since 247 — 128 gives a positive difference of 119, the digit 1 is placed in the second column of the binary digit row and the difference is carried forward to the next lower place value as shown in Table 1.7. Table 1.7: Place value method 256 128 4 |32[ 16 | 8| 4] 2] 1 247-256 | 247-128] 119-64 0 1 4. Continue with the operation until the digit in the right most side is evaluated. Table 1.8 shows the completed operation. Table 1.8: Place value method 256 128 64 32 247-256 247-128 119-64 55-32 0 1 1 1 16 8 4 2 1 23-16 71-8 1-4 3-2 1-1-0 1 0 1 1 1 ‘Therefore, the binary equivalent of 247, is 011110111, or H1110111, Example 1.5 Using the place value method, convert 45,, into a base 2 number, Solution eh 32 16 8 4 [2]1 Se 45—32=13|13- 16-3] 13-8=55-4=1|1-2| 1-1 fof 4 0 1 1 [fol 4 45,,=0101101, i, 101101, NB: You can ignore the 0 on the lft because it adds no value to the binary number, Example 1.6 Using both the place value and the long division method convert 107, into its binary equivalence, Place value method: For place value method, we need to write place values up to 128. 128 64 32 16 8 4 2 1 107 - 128|(107 - 64)|(43 - 32)] (11 - 16)] (11 - 8)(3 ~ 4) (@-2) |(1-1) 0 1 1 0 4 0 ‘ 1 107,,=1101011, Long division method. VON 3 3 Using the Place value and long division methods convert each of the following base 10 numbers to their binary equivalents. 1 10, 2. 43, 3. 365, 4. 512, * 5. 143,, 6. 954 0 1.5.3 Converting a binary fraction to decimal form decimal number whi: ‘ ee iif tents an of an integer and fractional partis called a real number. The real number increases from right to left in factors of 10 while that of the fractional part decreases from left to right i ft to right in factors of 10. Table 1.9 shi a umber 87.537 can be represented using the place values, ‘able 1.9 shows how a real ta 5 fable 1.9:Representation of fractional decimal numbers Place value 10' | 10° a : lot 1o? | 10% Decimal digit 8 7 . 5 3 7 Value 80 7 . 05 0.03 | 0.007 Fora binary number, the same approach as in Table 1.9 can be used only that the place values (weight) are based on factors of 2. For example, the binary number 11.11011, canbe represented as shown in Table 1.10. 2 Table 1.10: Representation of fractional binary numbers [Pucevane (2 |? |-|rlelel zl] 2 Binarydigt [1 |i |e {af 1 [olt 1 FValue in base ten ]2 [1 ]+ | 05 | 025 | 0 | 0.0625 | 0.03125 NB: When convertinga real number from binary to decimal, work out the integral and fractional parts separately then combine them. Example 1.7 Convert 11.011, to a decimal number. Solution Convert the integer and fractional parts separately, then add them up. 2x1 = 2,000 4 x12 +1,000 3.000. 0.50 x0 = 0.000 Weight De] [2 | 2? | 2 Binary digit Thiyejo fil 1. 0.25 x1 = 0250 i inbase io[2 [1 [-| 0 |025| 0-125 0.125 x1 = +0125 0.375, 3,000,, + 0.375, = 3.375» Thus 11.011, = 3.375, Example 1.8 Convert 11.11011, to its decimal equivalent. Solution Work out the integer part first. 2xt= 2 oe 212 1e4t @xtat TIA 310 Work out the fractional part i.e. 0.11011. 0.50 x1 = 0.50000 0.25 x1 = 0.25000 oPl=|22 | 2° [2 2 0.125 x 0 0.00000 ofli ji jo 1 1 0.0695 x1 = 0.06250 0 |- [0.5 | 0.25 [0.125 |o.0625 [0.03125 0.03125 x1 =+ 0.03125 0.84375, Combining the two parts we get; 3, + 0.84375,, = 3.84375,, Therefore the decimal equivalent of 11.1101, is 3.84375,.. 1.5.4 Converting a decimal fraction to binary form To convert a decimal integer to its binary equivalent, we continuously divide the number by 2. Inreal decimal numbers, we do the same for the integer part. However to convert the fractional part to its binary equivalent, we proceed as follows: 1. Multiply the fractional part by 2 and note down the product. 2, Take the fractional part of the immediate product and multiply it by 2 again. 3. Continue this process until the fractional part of the subsequent producti 0 or starts repeating the value of the original fractional part of the number being converted, 4, The binary equivalent of the fractional part is extracted from the products by reading the respective integer digits from the top downwards as shown by the arrow in Example 1.9. 5. Combine the two parts together to get the binary number, Example 1.9 Convert 0.375, into binary form golution eval digits downey paths2= 0.780 780.52 = 1,600 600 x2 = 1.000 (Fraction boo ‘Theretore 0.975, = 0.011, example 1.10 Convert the dacimal numbor 7,5625,, Into its binary equivalent, Solution Convert the two parts soparatoly staring with integer part: Tq = My Fractional part: Read this digits 4 0.5625 x2 = 1.125 0.1252 = 0.250 0.2502 = 0.500 0.5002 = 1.000 since the product ofthe fractional part Is zero, we stop here. 0,5625,, = 0.1001, Thus: 11140.1001 = 111.1001, Example 1.12 Convert the decimal nut Solution Convert the integer pat: Convert the fractional part: Lx2e0+ no 200) Examplo 1.11 Convort 0.40,, into its binary oquivalont Reau digits downwards Solution } 0.40x2 = 0.80 0.80 x2 = 1.60 0.602 = 1.20 0.20%2 = 0.40 0.402=0;8 (fractional part starts repeating) Looking at 0.40 x2, itgives the | original decimal fraction, This means that the bit is recurring ‘and has to be ignored. Therefore the binary equivalont of 0.40,, {sa recurring binary fraction 40,4 = 0.0110, +** N.B: The dots after the last digit means the number is recurting as follows: 0.40,, = 0.0110 01100110 0110++* ‘Thus in shor form :040,,= 0.0170, mer 4% into binary form. pia -o+$- (The fractional par starts repeating hence ignore.) By combining the integer and fractional parts, we get: 100, + 0.01, ... = 100.01, ment E: 1. Convert the following binary numbers to their decimal equivalents: (a) 0.10011, ©) 0.0010, (©) 0.10101, @ 11.0110, (© 10111110, (100.110, 2. Convert the following decimal numbers into binary equivalents: (@) 0.625,, &) 0.450, (©) 2.500,, . @ 5.1625, (©, 7.1875,, ( 0350,, 1.5.5 Converting octal numbers to decimal form To convert a base 8 number to its decimal equivalent, we use the same method as we did with binary numbers. However, it is important to note that ‘the maximum absolute value of an octal digit is 7. For example, 982 is not a valid octal number because digit 9 is not an octal digit, but 736, is valid because all the digits are ‘in the range of 0—7. Examples 1.13 and 1.14 demonstrates how to convert an octal number to a decimal number. Example 1.13 Convert 512, to its base 10 equivalent. Solution Write each number under its place value as shown below. Place 8 8 e value 64 8 1 Octal digit [5 1 2 Multiply each number by its place value: = (6x84) +(1 x81) 4 (2x8) 64x5 = 320 = (5x64) +842 8x4 8 =3204+8+2 1x2 242 =330,, oe Therefore 512, = 330, Example 1.14 Convert the octal number 1111, to its base ten equivalent. Solution [Place value si2| 64] 8 | ft [Octal digit 1 1 Al 1 Working out 512x1 = 512 64xt= 64 Bx1= 8 1xt=+ Therefore 1111, = 585,, Convert the following octal numbers to decimal numbers form: 177, 2. 4, 3. 102, 4. 1200, 5. 1000, kW LH Jog] 2019 6. 173, 7123, 8.777, 9. 345, 10. 166, 1.5.6 Converting octal numbers to binary form To convert an octal number to binary, each digit is represented by 3 binary digits because the maximum octal digit 7 can be represented with amaximum of 3 digits. See Table 1.11. Table 1.11: Binary representation of octal digits Octal digit __| Binary equivalents 0 000 1 001 2 010 3 Ol 2) 4 100 ¥ 3 101 — 6 110 QO 7 ul ny Example 1.15 mal 1.15, 1.16 and 1.17 demonstrate how to convert octal numbers to binary numbers. rmetane octal number 321, to its binary equivalent. sbiution “_Workingf0ih the left to the right, each octal number is represented using 8 binary digits and then ‘combined together to get the final binary number. Therefore: pe sft, 2 = 010; eee 001, Combining the three from left to right = * S| 2 1 Otte | 010 oot Example 1.16 Convert the octal number 526, toa binary number. Solution 5 2 6 101 | 010 | 110 Thus: 526, = 101010110, Example 1.17 Convert the octal number 332, to its binary equivalent. Solution 3 3 2 O11 }011 | 010 Thus: 332, = 011011010, i. the Bae Octal numbers to their binary equivalents: 1, 28%5 Needy 3. 162, 4, 565, 5.222, 7 f. 6337, 7.1413, 8. 1331, 9, gar, 10, 46653, : ime numbers to hexadecimal form . 0 ml Sto thei ers to their hexadecimal equivalents, simply group the digits ofthe binary number into groups of four bits fr eoriney hexadecimal equivalent of each igoup el to left e.g, 1101 0001. The next step is to write the "0lo- oD oor |; The hexadecimal equivalent of 1101 0001 is D/// or D1... Note that in computing, the letter Hin DIH represents the word hexadecimal. 1.5.8 Converting hexadecimal numbers to decimal form To convert a hexadecimal number to its base ten equivalent, we proceed as follows: 1. First write the place values starting from the right hand side. 2, Ifthe hexadecimal digit is a letter such as ‘A’ write its decimal equivalent. 3, Multiply each hexadecimal digit with its corresponding place value and then add the products. ‘The following examples illustrate how to convert a hexadecimal number to a decimal number, Example 1.18 Convert the hexadecimal number 111, Solution Place each number under its place value. 162=256, 16'=16, 16°=1 to its decimal equivalent," -. 1 1 1 256x1= 256 16x1= 16 ixt= +1 273 Therefore, 111,, = 2731 Example 1.20 Example 1.19 adecimal number A9,, to its | Convert the hexadacimal number 1A\ Convert the hex: « its base ten equivalent. Orin decimal equivalent 16? = 4 096]16? = 256/16! = 16]16°- 1 Solution 16 =1 1 A o [4 a 4096 x1 = 4096 256x10 = 2560 (Since Ais equivalent to 10,,) ‘Ain hexadecimal is equivalent to 10, 16x13 = 208 (Since Dis Therefore equivalent to 13, nto 13.) 16x10 = 160 1x1 = +1 1x9 = +9 6.865 Therefore 1AD1,_ = 6865,, Convert the following hexadecimal numbers into decimal numbers. 1.32, 2 CCD, 3 BFE, 4 119, 5 328, [Link],, 7. 10AFFD,, & DDFF34,, 9. LIABDF,, 10. CDFF31,, 1.5.9 Converting hexadecimal numbers into binary numbers 3ince F is'equivalent toa binary number 1111, the. ‘hexadecimal digits are therefore represented asing 4.a series of binary digits as shown jn Table 1.12. Table 1.12: Representation of hexadecimal numbers [Hexadecimal digit | _Decimalequivalent [Binary equivalent 0 00 0000 or or ‘00 a @ 0010 B G oom a a 100 o 6 O10 6 % 10 o7 7 or oF ® 1000 @ ® To0r i 10 1010 B n TOI c 2 TI00 2 1B Tor = 4 To E 5 TH i qe easiest method of conve Be erting a hi pexadecimel digit asa fOurbit binary nantes meer bi al digit as ae 1 binary form is ‘ oresponding positions as shown a umber and then arranging te aos according 0 et ample 1.21, , a Example 1.21 Gonvert 321,, into binary. solution Hexadecimal digit z inary equivalent 0 2 1 7 D010 | DOT Gombining the three sets of bits, we get 0011001000! 1321,. = 001100100001, Ot Example 1.22 Convert 5E6,, into binary. Solution [Hexadecimal digit 5 E 6 Binary equivalent 0101 1110 0110 526,, = 010111100110, Convert the following hexadecimal numbers into binary form 1 294, 2 247, 3 ERD, = 4 907), 5. BAD g 7, 585C,, 8 ABCD, 9. S5C3A,, 10. 3311ICF,, 6. CBDF,, 11, Convert 1111000110111, to hexadecimal equivalent ymbolic codes ber or special symbol is represented by astream of the coding scheme used. The most common Extended Binary Coded Decimal change (ASCID. 4.6 Data representation using Ss! Incomputing, a character ‘such as letter, numt bits: The number of bits per character depends on Coded Decimal (BCD), encoding schemes are: Binaty Interchange Code (EBCDIC) and American ‘Standard Code for Information Int: 1.6.1 Binary Coded Decimal (BCD) Binary Coded Decimal(BCD) is a 44-bit encoding scheme used to represent numeric data only. berepresented using Binary Coded Decimal as 1001,. Binary Iculators and microwaves. Forexample, anumber like 9 can Coded Decimal is mostly used on simple electronic devices like cal This is because it is easier to process and display individual numbers on their Liquid Crystal standard Binary Coded Decimal. Display (LCD) screens. To represent more characters, we use sy Conk! Decimal, that uses a G-bit representations, ric character example, letter A can be represent) Coded Decimal. A set of Binary Coded Decimal yy in Appendix I. “This is an enhanced format of Binar to represent 64 numeric and non-nume ‘as 110001, using the standard Binary Standard Binary Coded Decimal are provided it 1.6.2 Extended Binary Coded Decimal Interchange Code Extended Binary Coded Decimal Interchange Code (EBCDIC) is an 8 bit encoding scheme used primarily on IBM computers. total of256 2") characters ean be coded using this scheme For example, the symbolic representation of letter A using Extended Binary Coded Decing, Interchange Code is 11000001, See Appendix II for a detailed EBCDIC encoding scheme 1.6.3 American Standard Code for Information Interchange “American Standard Code for Information Interchange (ASCH) was a originally facturers have added a bit codin, a T-bit coding scheme that represented only 128 characters. However m: bit to this coding scheme which can now represent 256 char referred to as an 8-bit ASCIL. The symbolic representation of letter A ts is 1000001, Sce Appendix III for more details on ASCH encoding schem 1.7 Binary arithmetic operations In mathematics, the four basic anthmetic operations applied on number wre addition, subtraction, multiplication and division. In computers, the same operations are performed inside the central processing unit by the anthmetic and logic unit (ALU). However, the arithmetic a cannot perform binary subtraction directly. It performs binary complement For muluplocation and division, the ALU uses a method known as shifting before adding the bits. Because Multiplication and division methods is beyond the scope of this evel, we only demonstrate how digital computers perform binary addition and subtraction, 1.7.1 Representation of signed binary numbers fe three common ways of representing a signed binary number (positive In computing, there or negative). These are: 1 Profixing an extra sign bit to a binary number. 2 Using ones complement. 3 Using twos complement. Prefixing an extra sign bit In decimal numbers, a signed number has a prefix “+” for a positive number e.g. +27, and “-" for a negative number like 27,,, However, in binary, a negative number may be represented by prefixing a digit | to the number while a positive number may be represented by prefixing 4 digit 0. For example, 7-bit binary equivalent of 127 is 1111111, To indicate that itis positive we add an extra bit (0) to the left of the number ic. (0) 111111, To indicate that it isa negative pumber, we add an extra bit(1) ie. (IYI E TY (Q)ecan be represented in two ways ie, (O)OOIGH ‘Ones complement Normally, the term comple efer Forexample in Soom ett esto par which ogeter with ance makes le plementary angles add up to one right angle (90°), However jn computing, the idea of compl is postive and negative, iplement is used to address the problem of signed numbers i.e. ‘The problem of using this method is that 2er0 )00, or (1)0001000000, decimal numbers . - Eo thatofsis ee kof complement. Forexaplethe ines complement Fe Biwise NOT negation spplied oth 6. However, in binary numbers, the ones complement is Pe one operand) and pears number. Bitwise NOT isa unary operator (operates on 1100, is 0011, ie. O'saren - logical negation on each bit. For example, the bitwise NOT of 0101 101 is 1 10 100: regaled to I's while 1’s are negated to 0's. Likewise, the! bitwise NOT of 1010010, which represents “45,,. The bitwise NOT of 8-bit zero 00000000, is M1111, Looking at the two numbers, the most significant digit shows that the number has asign bit “0” for “+0” and “1” for “0”. Like in the method of using an extra sign bit, in ones complement, there are two ways of representing a zero. - Twos complement ‘Twos complement, equivalent to tens complement in decimal numbers, is the most natural way of representing negative numbers in computer systems. ‘The advantages of using this method are: LL. There are no two ways of representing a zero as is the case with the other two methods 2. Effective addition and subtraction ‘can be done even with numbers that are represented with assign bit without need for extra circuitries to examine the sign of an operand. ber is obtained by getting the ones complement then adding a The twos complement of a numt et the twos complement of a decimal number like 45,,, first convert it to 1. For example, to g sisbinary equivalent then find its ones complement. Finally, adda 1 othe ones complement as demonstrated in the following example: 45,)= 00101101, NOT (00101101) = 11010010 ‘Two's complement = 11010010, +1, = 11010011, 1.7.2 Binary addition ‘The five possible additions in binary numbers are 1. 0+0=0 2 O+1=1, 3. 1,+0=1, 4. 1,+1,=10, (read as 0, earry 1) 5. 1,4 1,+1,= 11, (readas 1, carry 1) ; The following examples demonstrated how to perform binary addition. Example 1.23 Find the sum of 111, + 011, Solution Arrange the bits vertically. Working from right to left, we proceed as follows: Step 1 1,+1,=10,, (Write down 0 and carry 1) Step2 1,+1,41,=11,, (Add the carry over digit to 1 + 1 in order to get 1 +1 +1. From the sum, write down digit 1 then carry 1 forward) Step3 1, +1, +0, = 10,, (Add the carry over digit to 1 + 0 in order to get 1+ 140. Since this is the last step, write down 10) Therefore 111, + 011, = 1010, This can be summarised in a table as shown below: 1" number 1 2" number 0 Carry digit = [Sum 10 lo} | Example 1.24 Find the sum of 00110, + 01101, Solution 1 number 0 2%number 0 0 1 on Carry digit Sum onso onan = = Example 1.25 Add the following binary numbers 10110, 1011, +m Solution ‘Add the first two numbers and then add the sum to the third number as follows: Step 1 Step 2 10110, 100001, +1011, 700007, ‘Work out the following binary additions 1 1010, ee + Il, 7 3 1011, —— + = at, +1, 4 1101, ; a +10110, mk 6. 1101, = lto10, 101, — +H, _ & 100011, 9. 101110, uu, 10101, umn, p10, + 1, + 1, 10. 1111111, 12. 110010, mi, io, + 1101, + 1100, 1.7.3 Binary subtraction Direct subtraction ‘The four possible subtractions in binary ae: 1. 0-0=0 2, 1,-0-1 3, 1,-1,£0 4. 10,-1,=1, Borrow L from thenext most significant digitto make 0 beeome 10, hence 10,-1,=1) The following examples illustrate binary subtraction using the direet method. Example 1.26 Work out the binary subtraction. 1101, = 1010, Solution Working from right to left, proceed as follows: Step1 1-0=1, Step 2 10-11 (Borrow 1 to make the current value 10, (2,) from the next significant digi Step3 0-0=0, Step4 1-1=0, Therefore, the difference in 1101, ~ 1010, = 11, Example 1.27 Example 1.28 Work out the binary subtraction. Work out the binary subtraction, 40101, 10011, 1100, - 110, Solution Solution 10011, 40101, - 1100, - 110, Ti, ‘Work out the following binary subtractions 1. 1001, 2 101, 3. 1011, 4, 1100, 5. 111011, 1010, - 100, -11L -Oul, — 110, 6 100010,-11, 7 O1101,-1011, 8. I1111111,~10101101, 9, 11101101,-100111, 10. 100000,~1111, 1.7.4 Subtraction using one’s complements i ‘main purpose of using the ones complement in computersis to perform binary subtractions ‘or example, to get the difference in 5 —3 using the ones complement, we proceed as follows dy Revit the: problem as 5 + (-3) to show that the computer performs binary subtraction by ling the binary equivalent of 5 to the one’s complement of 3. 2. Convert the absolute value of 3 into 8-bit equivalent i.e. 00000011 hi 4, Take the ones complement of 009000 of-3, Hie M1 ; 1100, which is the bit i Ee , he binary representation 4, Add the binary equivalent of Sto the one's coon tor ne’s complement of 3 ie overtow bit + HII11100, | imioo000001- Looking at the difference of the two bina 1. Iehns nine bits instead of ary numbers, you will observe that 2 The result shows that an The ninth bit is known as overflow bit. > ah he difference b " sonny tme; We know that it should be 0000 ie the (vo numbers is 100000001,. This is not ‘To address this problem in a syst : ee tem th x, to the 8-bit difference. The eo complement, the overflow bit is added back (00000001, + 1, = 00000010, which is the correct answer: Example 1.29 Using 8 bits, determine the one’s complement of 13, a Solution () Convert 13,, {ij Perform the bitwise NOT op: 0's. Therefore the ones compl The one's complement of 13,5 into an 8 bit binary number i.e. 00001101, Jeration on each bit such that zeros becomes 1's and ones becomes lement of 00001101, is 11110010, in binary form is 11110010 which represents ~13,.- 1.7.5 Subtraction using two’s complements Like in ones complement, the twos complement of a binary m positive number to its negative counterpart. For example, to get the the two’s complement, we proceed as follows: 1, Rewrite the problem as 5+(3). 2. Convert the absolute value of 3 into 3, Take the one’s complement 0f 00000011, ie. 11111100,- 4, Adda | to the one’s comp 00, to get 11111101, 5, Add the binary equivalent lement of 3 i.e. 00000101, Overfow bit + 11111101, ed [1]00000010, uae ; bit on the Jefimost side, the bit 6. By ignoring the overflow which is a binary equivalence of +2. wumber is obtained by negating @ difference in 5-3, using 8-bit binary equivalent i.e. 00000011, Jement ie. 111111 of'5 to the two's compl re 00000010 inary number 1s therefor Example 1.30 Using 8 bits binary notation, find the two's complement of 20; Solution The 8 bit binary equivalent of 20 is 00010100, One's complement 11101011, Add 1 = + de Two's complement == TTTOTT0O, ‘Thetwo'scomplomentbinaryequvalentof20, fs 11101100, whichisthenegativedecimal nmber(-29 ) Example 1.31 Using two's complement, work out 15,. ~ 8,9 in binary form. Solution 4. Convert 8,, to its binary equivalent then write its twos complement i.e. 00001000,. Ones gomplement NOT 00001000, = 11 110111, Twos complement = 11110111, + 1, = 11111000, 2. Add the two's complement to the binary equivalent of 15,.. _ Binary equivalent of 15,.= 00001111, ‘Adding the two numbers we get: 00001111, + 11111000, 3, Therefore 15 8 in binary form is a positive number: 00000111, (7,9) = (1)00000111, Example 1.32 Using the one's complement, calculate 3145-175 Solution 47, in binary is 00010001, 1's complement = 11101110, 31,, = 00011111, (00011111, + 11101110, = (1)00001101, : ‘Adding the overflow bit, we get: 00001101, + 1, = 00001110, or 1110,, Example 1.33, Using two's complement, calculate 27 - 5. Solution Binary equivalent of 27,, = 00011011, “Binary equivalent of 5,,= 00000101, spe tscomplement of5,,= 11111010, sre 2's complement of 5, =HMH1011, jdthe two numbers:11111014, 411111011, = 1 qperefore, the difference is 10110, (00010110, «4, Convert ~7,, to 8- " 1. vo 0 8-bit binary number using one’s and two's complement. 2. Using a sequence of 8 bits, find the two's complement of the following: (@) “31, 28, @ 5, x — ee following arithmetic operations using two's complement: MoT (b) 28,,-12,, (6) 34,,-33, (d) 100,,-50,, (©) 102,,~64,, 7 1. Explain the two types of data signals. ae 2, Differentiate between the following number systems: (a) Octal and decimal. oO (b) Binary and hexadecimal. ho 3. Convert the following binary numbers into decimal form: ¢ (a) 101110, (b) 101011, (c) 0110, (a) 10101, a 4, Convert the following decimal numbers to their binary equivalents, (a) 78% (b) $70, (©) 42 (@) 30, oO 5, Find the sum of the following binary numbers. - (a) 1110,+1111, (b) 001, + 100, > (c) 1101, + 1011, + 100, (d) 1010, + 101, a (e) 11,411, = Fs ES . Work out the following binary subtractions using direct, ones and twos conn methods. (a) 11001,- 1101, (b) 1000,-101, ©) lero (@ 10101110,- 1000110, @) 1000100010, —101, ae 7. Write down the character represented by the following codes: - (@) ASCII (b) — EBCDIC = (i) 0110000, (11110000, “ 3 (ii) o1loit1, Gi) 11110111, Y (ii) 1000011, (iii) 11000001, xe (ivy 1011001 (iv) 01011101, 8. Determine the binary equivalence of the following negative numbers using one’s and two's complement: (a) “7, (be) 80, ©) 100, 9. Determine the value of X in the equations: (a) 100110, —X, = 001010, (b) X,+1101,=70,, 10. Work out the decimal equivalent of the following binary numbers: (a) 0.10010, (b) 101.11, (©) 11.101, @) 0.001, 11. Work out the binary equivalents of the following decimal numbers: (a) 0.35, (b) 2.50, (c) 0.20, (d) 7.125, Chapter 2.1 Introduction outline 2.2 Data processing cycle Errors in data processing 2.4 Data integrity 25° Data processing methods 2.6 Computer files 2.7 Types of computer processing files 2.8 File organisation methods 2.9 Data processing modes 2.1 Introduction InForm 1 Book of this series, we defined the terms data and information. Data refers to the raw facts that do not have much meaning to the user and may include numbers, letters, symbols, sound or images. On the other hand, information refers to the meaningful output obtained after data processing. Incomputing, data processing refers to the process of transforming raw data into meaningful i d paper, mechanically output ic. information. Data processing can be done manually using pen an using: mechanical devices like typewriters or electronically using modem data processing tools suchas computers. Electronic data processing has become so popular that manual: andmechanical methods have become ‘obsolete. In this chapter, We discuss the fundamentals of data storage, integrity, access and processing. 2.2 Data processing cycle / / / ‘Je refers to the sequence of activities involved in data convertion from raw: ee rocesins ere gas acle because the ouput tained can Pe form to get information. It is often re ‘ d stored afer processing and may te used in future as input data, Generally, the four main stages of data processing cycle shown in Figure 2.1 are: 1, Data collection 2. Data input 3. Processing 4, Output | Data collction 7 Funure use / / ec Output Data Input | Processing | Fig. 2.1: Representation of data processing cycle 2.2.1 Data collection Data collection is also referred to as data gathering or fact finding. It is the process of obtaining, crucial data needed for processing. Methods of data collection Some methods of data collection include interviews, use of questionnaires, observation etc. In most cases, data is collected after sampling. Sampling is the process of selecting representative elements (¢.g. people, organisations) from an entire group (population) of interest. Some of the tools that help in data collection include source documents such as forms, and data capture devices such as a digital camera, Stages of data collection The process of data collection may involve a number of activities that may be classified into the following stages: 1. Data creation: This includes identification of the data required to meet a specific need and the process of collecting using tools such as questionnaires, interviews, and observation. 2. Data preparation: Data preparation involves verification and cleaning up of raw collected data by removing incomplete and erroneous entries. 3. Conversion: After preparation, data may need to be converted from one format to another e.g. from handwritten to spreadsheet files, 4. Validation: Data validation is the process of checking the accuracy and quality of source data before using or processing it. 5. Transmission: Electronic data may be transmitted physically or electronically for processing. 22.2 Data input ta nput refers to a process where th ‘machine readable form (binary f ary form). The o nay involve the following: rn). The conversion takes place in the input device and he collected da ‘ted data is converted from human readable form «Media conversion: Data may need to be converte fioma flash disk to hard disk for ere from one medium to another, such as ster input «+ Inputvalidation: Data entered i ‘ into the computers subject before being procean iputer is subjected to validity checks by a computer program bei ‘ed to reduce errors at the input stage. + Sorting: In case data need to be processing. (0 be arranged in a sequential order, it is_ first sorted before 2.2.3 Data processing is is the transformati i . eee . sfoemasion of npn data to a more meaningful output (information). Some ofthe processing op performed on data include calculations, comparing values and sorting 2.2.4 Data output ‘The final activity in data processing cycle is producing the desired output also referred to as information. The information can then be disseminated to the target group or stored for future use, Dissemination is the process of making the information available to those who need it and igsometimes called information sharing. The process of dissemination may involve electronic presentation over radio or television, distribution of hard copies, and broadcasting through Intemet and mobile phones. 2.3 Errors in data processing The accuracy of output from data processing task is in, garbage out (GIGO), therefore the accuracy of the the accuracy of the information produced. Some of the errors that influence the accuracy of data input and information output include transcription, computation and algorithm errors. very critical. As the saying goes, garbage data entered in the computer determines 23.1 Transcription errors ‘Transcription errors occurs during ‘errors. ata entry. Such ers include misreading and transposition Misreading errors ; —edocunet by incorrect reading of the source doc! Misreading exrors are human erors brought’ these curt “or example, a user may misread a sna wrong values. For examp % ay misread 2 nd fe auch, oe eat ype S86 sete ‘This is a transcription error in which the user con! S for an S. Transposition errors related mis At resul see vs are also human UlES fray, The ewo pes ST a itil haraces in the wrong order. For example, ere toad of368. Tanah ption errorscan beavoided by using modern data gy, devices uch as bar code readers, optical character readers, and digital eames, 2.3.2 Computation errors Computational errors occur when an arithmetic operation does not produce the expected res, The most common computation errors include overflow, underflow, truncation and rouyy, errors. Overflow errors An overflow occurs if the result from a calculation is too large to be stored in the allocate memory space. For example, if a byte is represented using 8 bits, an overflow will occur ifthe result of a calculation gives a 9-bit result. Truncation errors Truncation errors result from having real numbers that have a large fractional part floating point that cannot fit in the allocated memory space. The computer would truncate or cut off the extra decimals from the fractional part. For example, a number like 0.784969 may be truncated to four digit number: 0.784. Rounding errors Rounding errors result from increasing or decreasing the value of a digit in a real number to the required rounded number. For example, to round off 30.666 to one decimal place, we increase value of the first digit after the decimal point if its successor is more than 5. In this case, the successor is 6 therefore 30.666 rounded up to one decimal place is 30.7. If the successor is below S, e.g. 30.635, we round down the number to 30.6. 2.33 Algorithmic or logical errors ‘An algorithm is a set of procedural steps followed to solve a given computational problem. Wrongly designed algorithm would result in a program that runs but gives erroneous output. Such errors that result from algorithm design are referred to as algorithmic or logic errors. 2.4 Data integrity Data integrity refers to the validity correctness or completeness of data entered in a computer or rece om the infomation system. Integrity of data is measured in terms of accuracy, 2.4.1 Accuracy Accuracy refers to how close an approximation is to the actual value. As long as the correct - astrnctions and data are entered, ers inorder etal Prolue accurate results. In numbers, the accuracy accurate than 72:13 dt ounding egy nt PASS For expe, 72.1264 fs mor 2.4.2 Timeliness Timeliness is the relative accu . Timeliness of data and informaticn or ‘data in respect to the current state for which it is needed. hacked to them. Ifreecived late vs important because data and information have a time value example, information on the nena formation may have become meaningless to the user. For « : at is me i 3 Fast be printed prior ipthe eveiteintne ee people for a meeting or occasion 2.4.3 Relevance hes entered into the ome must be relevant in order to get the expected output. In this case, vance ; jeans : le data entered must be relevant to the processing needs and expectations. The user also needs relevant information for daily operations or decision making. There are several threats that compromise data integrity in terms of accuracy, timeliness and relevance. These include human errors, data transmission errors, software bugs, and natural disaster. Threats to data integrity can be minimised through the following ways: 1. Backup data\preferably on external storage media. 2, CoptzoLaccess [Link] Security- measures. 4 3, Design usét interfaces that minimise chances of invalid data entry. 4, Using error detection and correction s softwe when transmitting data over the network. 5, (ising devices that directly capture data from the source|such as barcode readers, digital cameras, and optical character reader. ractices when designing algorithms to minimize software bugs. 6. Follow best p as ao APY co OFS be ¥ oa 1. Define the following terms: 4 hen ng = ee pee td HA KA infin (a) Data processing. ~ segue got 9 ow a ’ (b) Data processing cycle.~ rue wal ane ie 2, Using an illustration, describe the four primary stages ce tbe io pro ° ss es le. ion. 72 YS i 3. Outline the stages of data collection. 7 ee uid _ You have come across the term garbage in garbage out (GIGO). What is its relevance ioerors in data cessing? paw pase OS Cow pa ronet n s o8 I fe f chineet 5. Explain the two types of transcription errors 6. State three types of computational errors." ca 46. vod, 4, ee ow CooGlih gs Gh 7. (a) Define the term data integrity. aa’ Cet i : (©) State thre facors that determine integrity of data, GC» (ere Tithe (c) State five ways of minimising threats to data integrity. 2.5 Data processing methods Once data has been collected, validated and verified, the user may choose any of. the three processing methods namely: manual, mechanical or electronic processing. In this section, we discuss merits and demerits of each of these methods. 2.5.1 Manual data processing In manual data processing, most tasks are done manually with a pen and a paper. For example ina busy office, incoming tasks (input) are stacked in the in ray: The processed tasks are then put in the out ‘ray (output). The processing of each task involve a person using the brain in order to respond to queries. ‘The processed information from the out tray is then distributed to the people who need it or stored in a file cabinet. Figure 2.2 shows an illustration of a manual data processing method. Fig, 2.2: Manual data processing on paper 2.5.2 Mechanical data processing Manual processing is cumbersome and boring especially when processing repetitive tasks. Mechanical devices were developed to help in automation of manual tasks. Examples of mechanical devices include the abacus, typewriter, printing press and weaving looms. Initially, these devices did not have any electronic intelligence. Figure 2.3 shows how a mechanical tool called abacus used to perform mathematical calculations Fig. 2.3: Abacus icus used to process mathematical data 2.5.3 Electronic data processing Fora long time, scientists have some form o| tien, iene on how to develop machines or devices that would made possible to some extent with tienen during data and information processing. This was developmentof programmable devices such as computers. ee aay 5 i op aeera technology has greatly enhanced data processing efficiency and capal ime ; Ie microprocessor controlled devices include computers, mobile phones calculators fuel pumps, digital television sets, and washing machines, Figure 24 shows an illustration of electronic data processing using a computer. Seller prepares invoice using Buyer prepares a purchase internal system order using internal system Buyer sends the order via e-mail, fax or post Sends invoice to the buyer Buyer receives invoice and via e-mail, fx or post prepares payment voucher Fig, 24: Blectronic data processing related records that give a complete set of information he stored manually ina file cabinet or electronically 2.6 Computer files A file can be defined as a collection of about a certain item or entity. A file can on storage media. Electronic storage offérs'a'much better way of | holding information than manual filing systems. Some of the advantages of electronic storage include: Information takes up less space compared to the manual filing. It is much easier to update or modify information stored electronically. Electronic storage offers faster access and retrieval of data. Storage in electronic databases enhances data integrity and reduces duplication. It enhances security of data than manual filing cabinets. yee 2.6.1 Elements of a computer file Generally, 2 computer file is made up the three elements namely: characters, fields and records Characters A character is the smallest element in a computer file and refers to a letter, number or special symbol that can be input, processed stored and output by a computer. A character is made up of a series of eight bits or less eight bits depending on the character coding scheme used. Fields A field isa logical combination of characters to represents meaningful piece of data. For example, ina students record, the admission number is an example of a field. Records A record is a collection of related fields that represent a single entity. For example, in a class mark sheet, details of each student in a row comprising of admission number, name, total marks and position make up a record. 2.6.2 Logical and physical files Computer files are classified into logical and physical files. The terms logical and physical are technically used to denote how a file is represented in terms of details and storage. Logical files A computer file is referred to as a logical file if it is viewed in terms of data items it contains and details of processing operations that can be performed on the data items, Because a logical file does not occupy storage space, it has no implementation details like field, data types, size and file type. Physical files A physical file is one that is viewed in terms of actual data stored on storage media and how the processing operations are made possible. Unlike logical files physical files have implementation details such as field size, data type and other attributes because they occupy storage space. = ee cree rete Processing tes yere are IS types of files use, aegap. The main common ty se for storing data needed for processing reference or esp report and sort file. Processing files includle master files, transaction, reference, 2.7.1 Master file A master file is the primi i Denote, ¢ ciiom ile es relatively permanent records of particular items, Le ean dete dae may contain details about the customers customer 1D, 2.7.2 Transaction file A transaction file is used to hold data duri i luring daily, weekly, or monthly tra i 8 le, in " » ly, or monthly transaction proc For example, ina supermarket, daily sales are recorded on a transaction file and later used to update the stock file. ing. 7a Reference file Reference file is mainly used for reference or look-up purposes. Look-up information is the information stored ina separate file but required during processing. For example, in a point of sale terminal, the item code read or using a bar code reader looks-up the item description and price from a reference file stored on a separate file. 2.7.4 Backup file Backup file is used to hold duplicate copies (backups) of data or information stored on fixed storage (hard disk). Since a file held on the hard disk may be corrupted, lost or changed accidentally, it is important to keep copies of the updated master and reference files in separate storage media or location. In case of hard disk failure, a backup file can be used to restore the original file. v .cted from the master or transaction 2.7.5 Report file store summarized reports extra ed from an inventory which is stored A report file is used to files, For example, you may obtain @ stock report generat separately as a report file. C 2.7.6 Sort file _ Sott files are used to store data which is arranged in a sequential order. Ase file is auily used where data is to be processed sequentially. In sequential process lata or reco! first sorted and held on a magnetic storage before updating the master Ie. 2.8 File organisation methods " How files are organized on the storage media is important because it determines the me, of access, efficiency, flexibility of storage. The four methods of organising files on a sty, media include: sequential, random, serial and indexed-sequential. ae, 2.8.1 Sequential file organisation Yeu %& She} “WOO He bye, In sequential fle organisation, records are stored and accessed in a sequential order. Retrieyay of records requires searching sequentially through the entire file from the beginning to the ey Because the records in the file are sorted in a particular order, better file searching methox), like binary search can be used to reduce the time used for scarching data from a sequentin) file. In binary search, it is possible to know in which half of the file records the target recon being searched is located. In other words, binary search this method repeatedly divides the soy of records in the file into two halves and searches only the half in which the value is found. fy, example, if the file has values 20, 30, 40, 50, 60 and the computer is searching for a value lik 50, it starts at 40 in its search ignoring the first half of the set. Advantages of sequential file organisation |. The sorting makes it easier to access records, 2. Binary search technique can be used to reduce record search time by over half the time that would have been taken without sorted records, Disadvantages of sequential file organisation 1. Slow in data access because sorting does not remove the need to sequentially access other records. 2. Sequential records cannot support modem storage technologies that require fast access to stored records. 3. Requirement that all records be of the same size is sometimes difficult to enforce. 2.8.2 Random file organisation ier ow Ble be SA Rainy In random or direct file organisation WASiNG are sored randomly but accessed directly on a storage medium. To access a file stored randomly, a record key is used to determine where a record is stored on the storage media. Magnetic and optical disks allow data to be stored and accessed randomly. Some of the advantages of random file access include: 1. Facilitates quick retrieval of records, 2. File records can be of different sizes, 2.8.3 Serial file organisation Gre Vee ou hens tof Qt(eof Orme “Uy Sratiy With serial file organisation, records in a file are stored and accessed one after another on a storage medium. The records are not sorted in any way on the storage medium. This type of organisation is mostly used on magnetic tapes. Figure 2.5 shows records of books stored serially ona magnetic tape. Record! — Record2 Record 3 Magnetic tape [x fo} | mG t Inter record gap (IAG) Fig. 2.5; ‘is. 2.5: Records on magnetic tape Advantages of serial file organisation 1, Itis simple to store data scrially on media such as tapes 2. It is cheaper to store data in serial format, : Disadvantages of serial file organisation 1. Itis cumbersome te search for a specific record because you have to access all preceding records before retrieving the search target. 2, Wastage of space on medium in form of inter-record gap. 3, Serial access does not support modem high speed requirements for quick record access. 2.8.4 Indexed-sequential file organisation This method is almost similar to sequential method only that an index is used to enable the computer to identify individual records on storage media, For example, on magnetic drum, records are stored sequentially on the tracks. However, each record is assigned an index that can be used to directly access it. 2.9 Data processing modes ‘There are several ways in which a computer, under the influence of an operating system is designed to process data. Examples of processing ‘modes include: BA yen olive! 1. Online processing dahl ee, ‘ pow : 2 Real-time processing ¢ noe yon ieee dite d 3. Distributed processing aed 8% Tins shane pp he meg eh Bolden 4. Time-sharing- 5. Batch processing pains ratehule 6. Multiprocessing Nathaly loleroake prea, 7, Multitasking ranks grec, | 8. Interactive processing ee processing mote computer knownas server. tomatically on are Inontne data processing, datais processed auOP rein The data input may ‘The computer is connected directly © input be through a network terminal or an input device attached to the computer ar;mobile dey, known as the client, Examples of online processing include intemet banking, online pay. and online travel booking, 2.9.2 Real-time Processing In real-time data processing, a computer processes the incoming data as soon as iLoccurs any -[Link] immediate in real time. It is important to note that an online processing system may }. considered as real-time ifit provides immediate feedback upon receiving request from a remo, client. The main purpose of a real-time processing is to provide accurate, up-to-date informatio, based on the received input, An example of real-time processing is making a reservation {j,; airline seats. A customer may request for an airline booking information through a remo: terminal or mobile phone. Ifa booking is made, the system immediately updates the reservation, file to avoid double booking and sends the response back to the customer in real time. 2.9.3 Distributed data processing Distributed data processing refers to dividing and distributing processing tasks to two or more computers that are connected through telecommunication network, There may be a central computer that receives input from the remote computers, processes the data and updates the transaction or inventory file. To improve efficiency in most online and real time systems, mos: banks that have networked their branches use distributed processing. The branches send customer requests to distributed servers. The server closest to the client processes the request and then sends back the response through the communication channel to the remote client. 2.9.4 Time-sharing Time sharing method of processing means that several terminals connected to a central server are concurrently given-aeeess to the central pracessing unit (CPU). However, in actual sense, each useris allocated a time slice of the CPU in sequence. The amount of time allocated to each user is controlled by a multi-user operating system. For example, in time sharing technique known as round robin, if a user's task is not completed during the allocated time slice, the task is removed from the CPU until it is re-allocated another time slice later in round robin. 2.9.5 Batch processing In batch processing, data is accumulated into a batch over a specifi is ime e.g. daily. weekly or monthly. The batciris then processed at once. For example, in a payroll processing systems, employees” details conceming number of hours worked, rate of pay, deductions details are collected for a period of time, say one month. This details are then used to process gross and net payment for the duration worked. 2.9.6 Multiprocessing ~ 5 tu tha 5 ea, liprocessing rela t0 pitch ispossible in distribute such system computer mat together in synchronized ma from two or more different p ‘This synchronized operation enables different processors ems Servers and mule 's apparently at the [Link]. This ¥ contain more than ser computers such as mainframes. In nen, Ata ae ham oe central processing unit which work rograms or from am the processors may execute instructions n is made possibl " tale Parts of one program simultaneously. to share resources ya multiprocessing operating system that such as disks and main memory. 2.9.7 Multiprogramming veer too bug. & wocesk, YE UR te. . Multiprogramming, also referred 1a o porcaiiy “AW Senn toasn if * tasksare processed apparently ra Hi-tasking refers oe of processing where several TEE Ua BS Opposed to rulprocen ey ie cea processing uml. Kisirparat ; essing, multiprogramming, appli that hi only one central processing a 12, applies to a computer that has Sots what on ae tera a The operating system allocates each program a time slice and aes executed, This scheduling is done so quickly thatthe user gets impres all programs are being executed at the same time. 2.9.8 Interactive processing Interactive systems process data by prompting the user to provide inputas data or instructions. A good example of interactive processing is use of Automated Teller Machine (ATM) to withdraw ‘or deposit cash, For example, during cash withdrawal, an ATM prompts the user for responses such as Personal Identification Number (PIN) and amount. The machine then displays the details for confirmation of the action the user has initiated, Benefits of electronic processing Having discussed some of the data processing modes, in this section we discuss some of the benefits and limitations of electronic data processing modes. 7 Benefits of electronic data processing include: x \ #Q 1. Efficient processing especially where all required data is available. : \\ oe 2 Convenient access and availability of data and information digitally. wi i 3. Distance between entities that are processing data is made nonsignificant. \ i 4. Support for global information sharing and collaboration on intemet. processing include: Limitations of electronic data compromised during storage 1. Security of data may be appropriate measures are not taken. ; / 2 Lack of lezal frameworks in many counties tht should Suppor online and distributed electronic processi or while in transit on networks if g activities / 10 support electronic data processing. ile among many workers t j ahi aa Revision Exercise 2 Distinguish between data and information. Describe types of data processing methods . State four advantages of storing data in computer files over the manual filing system. State elements that makes up a computer file. 1 2. 3. 4. 5. Differentiate between a logical file and physical file. 6. Explain six types of computer files giving an example in each case. 7. Distinguish between the following: (a) Sequential and serial file organisation methods. (b) Random and indexed-sequential file organisation methods. Describe five types of electronic data processing modes. — TR aT TaN @ ELEMENTARY PROGRAMMING PRINCIPLES Chapter 3.1 outline 3.2 3. 34 35 3.6 37 38 39 3.1 Introduction Introduction Introduction to computer programming Description of programming terms Levels of programming languages Program development Program documentation Designing program algorithns Program control structures Design of complex algorithms Human beings have evolved from the stone age to a highly sophisticated and advanced society by inventing ultra modem devices like computers. The idea of computers programming started ‘way back in the nineteenth century. The first programmable computerscalled Electronic Numeric Integrator and Calculator (ENIAC) is depicted in Figure 3.1. Note that, unlike modern digital computers, ENIAC was progranmed using a combination of plugboard wiring and portable function tables. But what is computer programming? This chapter seeks to answer ‘the question by describing and demonstrating some of the fundamental computer programming concepts and skills. Fig, 3.1: Electronic} Numeric Integrator and Calculator 3.2 Introduction to computer programming As mentioned earlier, a computer works by executing a set of instructions known as a progray, The term programming therefore refers to the process of developing computer instructi., (programs) to solve a particular problem, Programming involves use of special characters, si, and symbols found in a particular programming language to write the set of instructions, programming language has a special set of symbols that can be translated into machine readab). (binary digits) form by the computer. Each programming language has a special sequence, order of writing characters usually referred to as syntax. It is John von Neumann of Princeton University (USA) who first came up with a design to stor. programs in the computer memory. Perhaps, this was one of the most dramatic developmen, in the computer history. Why? This is because not only did the new stored-program increas. the processing speed but also allowed easy and flexible methods of editing a program. 3.3 Description of programming terms Before we go further with programming, it is important to define some common terms used in computer programming. These include source code, object code, translators namely: assemblers, interpreters, and compilers. cx na ty to prensldsn, be 3.3.1 Source code - ee eda The term source code refers to the instructions that the programmer writes in the program editor window that are not yet translated into machine readable form. The source program is usually created using a particular programming language like Pascal, C, C++, Visual Basic, and Java. . ae 33.2 Object eode 4 1th ay Gal Wwe be bog WAT ‘The term object code refers to the program code that is in machine readable (binary) form. A source code that is not in machine readable form must be translated into object code. 3.3.3 Translators

You might also like