Download as pdf
Download as pdf
You are on page 1of 115
INFORMATION REPRESENTATION 1 Information representation 41.4. Data Representation Candidates should be able te: ‘Show understanding of binary magnitudes and the ifteence bet ry peeixes and dacimal ‘Show understar differnt number 9) Perform binary addition and subtraction Character data in its intemal binary form, depending Notes and guidance ferstand the difference between and use: bland Keio mebi and mega obi and giga tobi and tera he binary, denary, hexadecimal number sases and Binary Coded Decimal (BCD) and one’s and two epresentation for bina (American Standard Code fr Ink Interchange), extended ASCil and Unicode. ‘Students will not be expected to memorise any Denary Number System: We know decmal or denary number system has (base 10) This uses digs 0 to 9 and has place values below 10000 1000 100 I 10 units geo ees cee Pee eee Binary number system: The binary system on computers uses combinations of Os and 1s and has (base 2). 128 64 16 8 4 2 1 (27) (28) (2) (28) (23) (2H). (2) Binary place values You can also break a binary number down into place-value columns, but each column is a power of two instead of a power of ten. For example, take a binary number like 1001. The columns are arranged in multiples of 2 with the binary number written below: PLACE VALUE By looking at the place values, we can calculate the equivalent denary number That is: (1x 2°) + (Ox 2?) + (0x2!) + (1x2") = 8404041 (1x8) + (0x4) +@x2)+(xl=84+1 =9 CONVERTING BINARY TO DENARY large binary number like 10101000 we need more place values of In denary the sum is calculated as: (1x27) + (0 x 2°) + (1x 25) + (0x 24) + (1.x 2°) + (0x 27) + 0 x2') + (Ox2") = 168 (1x 128) + x 64) + (1 x 32) + (Ox 16) + (1x 8) + (Ox 4) + (Ox 2) + Ox 1) = 128 + 32 68 Convert between dena Place | Place | Place | Place | Place| Place | Place | Place value | value | value | value | value | value | value | value 128 | o | 32 | 16 | 8 | 4 CONVERTING DENARY TO BINARY ods for converting a denary (base 10) number to binary (base 2). Place Values 64] 32/16/8 |4}2/1 Method:2 - Converting a denary number to binary Worked example: Denary number 84 We need to check which numbers place values can be added to make 84. We will put 1 under the numbers to e added and 0 under the numbers which are not added. We select Place value 64 so we put | under We select place value 16 and put | under it We selected place value 4 and put | under it. Adding 64+16+4 gives us 84 so our number becomes: 64 32 16 8 Result: 84 in denary is equivalent to 1010100 in binary Activity 1A- first 5 questions Activity 1B-first 5 questions Activity 1C BINARY ADDITION lary numbers 011 and 100. ‘Write the numbers out using the column method. Start from the right, and simply add the numbers. o11 +100 111 111 is 7 if converted back to denary. Example: Adding two 1s in the same colum: Sometimes a binary addition will require you to carry over values into the next highest place- value column, eg when finding the sum of the binary numbers 0010 and O111 There is a clash when adding two ones in the same column. In binary, 1+1 is 10 - it has to become 0 with | carried over. 0010 +0,1,11 1001 1001 is 9 if converted back to denary. 2 + 7 = 9 in denary +ve and —ve binary numbers (signed numbers) ‘When computer stores binary numbers, we have to differentiate +ve binary numbers from —ve binary numbers. Unfortunately (-) or (+) sign cannot be displayed rather only 0/1 can be used in binary. Rules of +ve and —ve binary numbers Positive binary number always starts with 0 in MSB (Most significant bit) © Negative binary number always starts with 1 in MSB (Most significant bit) e.g +ve number: 01010010 -ve number: 10010110 “128 Place Values Number becomes 3+ O 1 0010 so number is 0+64+16+2 = v Sign bit +ve part of number Negative binary number always starts with 1 in MSB (Most significant bit) 128 Place Values ‘Number becomes 1.0.0 1 0110 sonumberis -128+16+4+2 = -106 v v Sign bit +ve part of number Conversion of -Ve Denary number to Binary: What is - 65 49 in binary? Two's complement allows us to represent signed negative values in binary, so here is an introductory demonstration on how to convert a negative decimal value to its negative equivalent in binary using two's complement. Binary addition and subtraction Up until now we have assumed all binary numbers have positive values. There are a number of methods to represent both positive and negative numbers. We will consider: © one’s complement ® two's complement. In one’s complement, each digit in the binary number is inverted (in other words, 0 becomes 1and 1 becomes 0). For example, 65 = 01000001 in binary ‘St8p12! invert 1 to 0 and 0 to 1 we get: 01000001 to its one’s complement as below: 01000001 = — 10444110 In two's complement,binary digit 1 is added to one’s compliment ‘Stepl3! Convert 10111110 Binary to its two's complement by adding 1 to the one's complement. 10111110 10111111 = Two's complement ‘Two's compliment of a positive number will make it a negative number 28 64 3216 8 4 2 1 Place values o441114 = -128 + 32 +16+8+4+2+1 = 10111111 is - 65 in binary. We know this it true because if we add (01000001 (+65) to 1011111 1b (-65) and ignore the carry bit, the sum is 0, which is what we obtain if we add +65 + (-65) = 0. 01000001 +65 + 10111111 -65 ° 00000000 denary j, What mates is that orginal numberof bits (7-00) ae al. Sra arte What is Binary Subtraction? ‘Subtraction of binary numbers is an arithmetic operation similar to the subtraction of decimal numbers or base 10 numbers. For example, 1+ 1+ 1=3in base 10 and 1+1+1=11 in binary number system. When you add and subtract binary numbers, you will need to be careful when borrowing as these will take place more often. When you subtract several columns of binary digits, you must take into account the borrowing. When 1 is to be subtracted from 0, the result is 1 where 1 is borrowed from the next highest order bit or digit Binary Subtraction Table ‘The subtraction of binary numbers is given by: Binary Number ‘Subtraction Value 0-0 0 1 1 (Borrow 1 from next high order digit) 0 Example 4: Decimal Equivalent : 0 0110140=26 0 001100=12 Thoreforo, 26-12= 14 The binary resultant 9034 0 is equivalent to the 14 2 = 1=4 (donary) two numbers into binary anne 0100010 he two's complemer rt the digits: dd 1 which gi 3 Add 05 and -68 “128 64 The additional ninth bt is simply ignored leaving the binary number the correct result ofthe subtraction) Overflow A CPU with a capacity of 8 bits has a capacity of up to 1111111 in binary. If one more bit was added there would be an overflow error. Sorry, this clip is not available in your region or territory An explanation of binary overflow errors Example: 8-bit overflow An example of an 8-bit overflow occurs in the binary sum 11111111 + 1 (denary: 255 + 1). 11991114 0,0,0,0,0,0,0, 1 100000000 The total is a number bigger than 8 digits, and when this happens the CPU drops the overflow digit because the computer cannot store it anywhere, and the computer thinks 255 + 1 = 0. Activity1D-c,d,i,j Measurement of the size of computer memories Unit byte ‘kilobyte (KB) ‘1 megabyte (MB) ‘A gigabyte (GB) {terabyte (TB) 1 petabyte (PB) J exabyte (EB) ‘Size in Bytes byte 1024 bytes 1,048,576 bytes (1,024 KB) 1073,741,824 bytes (1,048,576 KB) 1,099,511,627,776 bytes (1,073,741,824 KB) 1125,899.906,842,624 bytes (1099511627,776 KB) 1152,921,504,606,846,976 bytes (1,125,899,906,842,624 KB) nibble=4 bit ve sosine : tea ouzsoye ia’) ‘le ostyte ‘ie toe teas 9 toi (20 100000000 bee ‘terabyte (TB) -4000,00000000 bytes ‘A petabyte (P) Terabyte EB) In this table, the sizes of computer memory are represented in decimal unit: where 1 kilobyte is equal to 1,000 bytes, 1 megabyte is equal to 1,000,000 bytes, and so on. PNRM le 1k Kibibyte (KiB), Mebibyte (MiB), Gibibyte (GiB), Tebibyte (TiB), and Pebibyte (PiB) are binary-based units of measurement for computer memory. They were introduced as alternatives to the decimal-based kilobyte (KB), megabyte (MB), gigabyte (GB), terabyte (TB), and petabyte (PB) units to provide more accurate representations of memory sizes in binary terms. Name of memory size Equivalent denary value (bytes) 1 kibibyte (1 KiB) 1024 1 mebibyte (1 MiB) 1.048 576 1 gibibyte (1 GiB) 1073 741 824 1 tebibyte (1 TiB) 1099 511 627 776 1 pebibyte (1 PiB) 1 125 899 906 842 624 Here's a breakdown of these units: Kibibyte (KiB): Equal to 1024 bytes. The prefix”kibi” represents 2°10 (1,024), aligning with the binary nature of comput tems. KiB is often used in technical specifications and computer science contexts. Mebibyte (MiB): Equal to 1,048,576 bytes or 1,024 kibibytes. The prefix "mebi" represents 2°20 (1,048,576), aligni h the binary nature of computer systems. MiB is commonly used to measure larger amounts of computer memory. Gibibyte (GiB): Equal to 1,073,741,824 bytes or 1,024 mebibytes. The prefix "gibi" represents 2°30 (1,073,741,824), aligning with the binary nature of computer systems. GiB is used to represent even larger memory sizes. Tebibyte (TiB): Equal to 1,099,51,627,776 bytes or 1,024 gibibytes. The prefix "tebi" represents 2°40 (1,099,511,627,776), aligning with the binary nature of computer systems. TiB is used for very large memory sizes, typically encountered in storage devices and data centers. Pebibyte (PiB): Equal to 1125,899,906,842,624 bytes or 1,024 tebibytes. The prefix "pebi” represents 2°50 (1,125,899,906,842,624), aligning with the binary nature of computer systems. PiBis used to repr extremely large memory sizes. These binary-based units (KiB, MiB, GiB, TiB, PiB) provide more precise measurements of memory sizes in binary arithmetic and are particularly useful when dealing with digital storage, data transfer rates, or memory capacities. Tet NE NUMBER SYSTEM crit oN The hexadecimal system is very closely related to the binary system. Hexadecimal (sometimes referred to as simply hex) is a base 16 system with the weightings: 1048576 65536 4096 256 16 1 (168) (164) (16%) (162) (16) (169) Because it is a system based on 16 different digits, the numbers 0 to 9 and the letters A to F are used to represent hexadecimal digits. A= 10, B= 11,C = 12, D= 13, E= 14 and F = 15. Since 16 = 2 4, four binary digits are equivalent to each hexadecimal digit. Table 1.3 summarises the link between binary, hexadecimal and denary. ia’) crit oN 1100 mit CONVERT 101111100001 FROM BINARY TO HEXADECIMAL. Solution First split it into groups of 4 bits: 1011 1110 0001 Then find the equivalent hexadecimal digits: B E 1 (a9) Convert10000111111101from binary to hexadecimal. Solution First split it into groups of 4 bits: 10 0001 1111 1101 ‘The left group only contains 2 bits, so add in two Os to the left: 0010 0001 1111 1101 Now find the equivalent hexadecimal digits: 2 1 F D HOMEWORK Noam ia as 10011101110 000111100001 100010011110 0010011111110 0111010011100 CONVERT THIS HEXADECIMAL NUMBER TO ITS BINARY EQUIVALENT. ASA Solution Using Table 1.3, find the 4-bit code for each digit: 0100 0101 1010 Put the groups together to form the binary number: 010001011010 USE OF THE HEXADECIMAL SYSTEM Memory dumps It is much easier to work with: BSA41AFC than i is to work with: 10110101101001000001101011111100 So, hexadecimal is often used when developing new software or when trying to trace errors in programs, When the memory contents are output toa printer or monitor, this is known as a Memory Dump ia’) crit oN ZA program develope can look at each ofthe hexadecimal codes (2s how In and determine where the error lies. The value on the far left shows the memory location, so itis possible to find out exactly wherein memory the fault occurs Using hexadecimal is more ‘manageable than binary. Its a powerful fault-tracing tool, but requires considerable knowledge ‘of computer architecture to be able to interpret the results looss0re0 sa 20 61 6E 20 65 78 69 6B 67 a HOMEWORK BCD-BINARY CODD DECIMAL In computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Special bit patterns are sometimes used for a sign or for other indications (e.g., error or overflow). 0000=0 0101=5 0001=1 0110=6 0010=2 0111=7 0011=3 1000=8 0100=4 1001=9 Therefore, the denary number 3 1 6 5 would be 00 11000101100101 in BCD format The 4-bit code can be stored in the computer either as half a byte or two 4-bit codes stored together to form one byte. For example, using 3 16 5 again Method 1: four single bytes 0 [0 0 |o 0 |o [o |o Method 2: two Convert these denary numbers ito BC Uses of BCD There are a number of applications where BCD can be used. © the obvious type of application is where denary digits are to be displayed, for instance on the screen of a calculator or in a digital time display. {80.3 ® 4 somewhat unexpected application is for the representation of currency values. When a currency value is written in a format such as $300.25 it is as a fixed-point decimal number (ignoring the dollar sign). It might be expected that such values would be stored as real numbers but this cannot be done accurately. THE MOST OBVIOUS USE OF BCD IS IN THE REPRESENTATION OF DIGITS ON A CALCULATOR OR CLOCK DISPLAY Consider adding $0.37 and $0.94 together using fixed-point decimals. $0.37 00000000.00110111 + + $094] |0 0000000 .1 00101 0 0| |Expected result = $1.31 Using binary addition, this sum will produce: 00000000. 11001011 which produces 1 1 0 0 (denary 12) and 101 1 (denary 11), which is clearly incorrect. The problem was caused by 3 + 9 = 12 and 7 + 4 = 11, as neither 12 nor 11 are single denary digits. The solution to this problem, enabling the computer to store monetary values accurately, is to add 0 1 1 0 (denary 6) whenever such a problem arises. The computer can be programmed to recognise this issue and add 0 1 1 0 at each appropriate point. i : a ae) ero Ara Ae Goss 2) Sum £ 9, Final Corry = 1 (ECT seenoete WEISS) Rafe 3) Sum > 9, Final Corry = 0 eerie) MSBbco eae re orn Solution: Decimal number of the given BCD numbers are as below: 01110101gcp = 7519 and 00110101gcp = 3519 C > 0111 0101 75 + 0011 0101 +35 1010 1010 Bothleftand right cD 110 ‘numbers are invalid. So | #0110 40110 wewouldaddstoboth — \wmnuiiiactscom/! $$. tthe 8c numbers. 0001 0001 0000 oH uy 1 1 o Step 1: Add the two BCD numbers, using the rules for binary addition. Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number. Step 3: If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is generated, it is an invalid result. Add 6 (0110) to the 4-bit sum in order to skip the six invalid BCD code words and return the code to 8421. If a carry results when 6 is added, simply add the carry to the next 4-bit group. Revision Monday 17th July (One of the colours used in the image has the hexadecimal colour code: #502388 FC is the amount of red, 23 is the amount of green and sa is the amount of blue in the colour. () Convert the hexadecimal code Fc into denary. 1) ‘The amount of green in binary is 00100012. This has the denary number 15 added to it to create a second colour. ‘Add the denary number 15 to the binary number 00100011 and give your answer in binary. Perform the addition in binary. Show your working. Working ncrssnunnnns ssn sos Answer (in binary) a (iii) Hexadecimal 23 in two's complement representation is 00100011. The denary number 110 needs to be subtracted from this value. ‘Subtract the denary number 10 from the two's complement representation 00100011. Give your answer in binary. Show your working. Converting -10 to two's complement binary 1111 0110 Adding values Final answer 0001 1001 10= 0000 1010 -10=1111 0110 0010 0011 + 1111 0110 0001 1001 11 11 ASCII codes and Unicodes Encoding The Process of converting the data from one form to another is called Encoding Computer only understand binary language of ‘sand O's Therefore when thekey on the keyboard is pressed, it is internally mapped to a unique code. Which is further converted to binary, EX: When a key “B" is pressed, it is internally mapped to a decimal value 66, which is then converted into its equivalent binary value for the computer to understnad ASCII ASCII stands for the "American Standard Code for Information Interchange’. It was designed in the early 60's, as a standard character set for computers and electronic devices ASCIl is a 7-bit character set containing 128 characters. It contains the numbers from 0-9, the upper and lower case English letters from A to Z, and some special characters The character sets used in modern computers, in HTML, and on the Internet, are all based on ASCII The following tables list the 128 ASCII characters and their equivalent number. ASCII TABLE Decimal Hex Char [Decimal Hex Char Decimal Hex Char | Decimal Hex Char ° ofa) x zo (sncel [ee ae 9 oO i 1 siarornezona) | 33 a les a A [or 6 2 2 (Swarortem Fy 2 + les 8 |e s 8 5 3 exoorrex 35 3 ler e159 6 ¢ 4 4 wroorrmuswssion | 36 2s fea BD fies 5 Ss iNounr 7 2 8 leo e fio % é & © cewomeocer 38 2% & = |7 e fio 66 Ff 7 7 meu 38 2 n 6 |i og 8 8 fescesoce) 40 wo Ie a ° 3 oazomune ar wo |e 6 fis gs 10 a ue reo) 2 mt ite 4 [ie GA n 8 vernon ma) 3 we + ls x |ior sk 2 © omer a x | |% t fio bet 1% D fowmucerersey) | a5 20 Ia m |i00 6m 1s © saeroun 4% x. |e ufo 6e om 13 Faery ® 1 |e ofan or 16 to fowaumcescare) | 48 goo ao efi mp 7 11 bewcecomany — | no fa qo fis on 4 18 12 pencecounot 2} | 50 22 le Roti 18 13 ewcecomasy | 31 33 [as so |is as 20 14 Dever cowma.s) | 32 nn (71 7 lus mt n 15 necarve commence) | 53 35 [as uo fi su 2 16 (smomowousou) | 50 3s ste vo fie ey 23 17 fenoorreans aicen_ 155 yo Ie wine ow 2 18 (owcay 56 se fas x |i ex 2 19 eADOr EDU) 37 a ( y faa ” y 26 1A (suesmrure 58 hf 50 z fin ao 2 ie scwe) 38 x [ot tc im et 3 ie fesemesron, 60 xe Ie Vo |aze ref 2 10 onoveserarony |x 3 = [35 1 fis} 30 Te (RECOROSemaRATOR) | 62 se > oe w]e oe a AF uursenssaron) 6 7? dos 7 joey vw schools Indian Script Code for Information Interchange (ISCI) It is a coding scheme for representing various writing systems of India. It is an 8-bit code representation for Indian languages i can represent 25=256 characters. 0 hex 61 (lower case) 0 hex 41 (upper case) 0 hex 79 (lower case) 0 hex 59 (uppercase) 00 00 11 a4: Notice the sixth bit changes from 1 to 0 when comparing lower and uppercase characters. This makes the conversion between the two an easy operation, It is also noticeable that the character sets (such as a to z, 0 to 9, and so on) are grouped together in sequence, which speeds up usability Extended ASCII uses 8-bit codes (128 to 255 in denary or 80 to FF in hex). This allows for non- English characters and for drawing characters to be included. ince ASCII code has a number of disadvantages and is unsuitable for some purposes, different methods of coding have been developed over the years. One coding system is called Unicode. Unicode allows characters in a code form to represent all languages of the world, thus supporting many operating systems, search engines and internet browsers used globally. There is overlap with standard ASCII code, since the first 128 (English) characters are the same, but Unicode can support several thousand different characters in total. As can be seen in Tables 1.5 and 1.6, ASCII uses one byte to represent a character, whereas Unicode will support up to four bytes character Unicode * Unicode has been developed to incorporate alll the characters of every written language of the world * UNICODE provides a unique number for every character. * Commonly used UNICODE encoding are UTF-8, UTF-16, UTF-32. Despite still being widely used, the ASCII codes are far from adequate for many purposes. Unicode is an international encoding standard for use with different languages and scripts. Unicode It works by providing a unique number for every character, this creates a Consistent encoding, representation, and handing of text Basically Unicode is ike a Universal Alphabet that covers the majority Of diferent languages across the worl, it transforms characters into numbers. Itachieves this by using character encoding, which is to assign a ‘number to every character that can be used. What's an example of a Unicode? Unicode has its own special terminology. For example, a character code is referred to asa In any documentation there is a special way of identifying a code point. An ‘example is U+0041 which is the code point comesponding to the alphabetic character A. The 0041 are hexadecimal characters representing two bytes. The interesting point is that in a text where the coding has been identified as Unicode itis only necessary to use a one-byte representation for the 128 codes corresponding to ASCII. To ensure such a code cannot be misinterpreted, the codes where more than one byte is needed have restrictions applied A S-8-—On Bop §-—=—epege ee Zi i >Yakovoe ely : olix |x del xeakove kris - FN EORS Hols gwhlobe inl + aioe g> ie i> foie hekola Rie > oss kos Bee visio jr ele feb imie ls # mfp gal) ole gw Ee as = fev ge oli gobo wir = |B] | << BO fal 0/5) leet feo le ig +2 —| fozege ai

You might also like