GET130 Intro to Engineering Technology Lab 5: Computer Engineering Technology References: 1. Binary numbers: http://en.wikipedia.org/wiki/Binary_number 2. Powers of two table: http://www.umass.edu/wsp/statistics/tables/powers2.html 3. Number base converter: http://www.aet.calu.edu/~jsumey/php/baseconverter.php 4. Binary prefixes: http://en.wikipedia.org/wiki/Binary_prefix Introduction: An important part of working with computers is understanding the “language” they use: binary. As humans, our native number system is decimal (base 10) because of the number of digits on our hands. However, computers store and transfer information in terms of digital logic levels (voltages) using only two discrete values, i.e. high/low, on/off, true/false. Thus, the two-valued binary system is ideal for mathematical representation of computer information. The binary digits, aka ‘bits’, are 0 and 1. Everything in binary is either 0 or 1. This lab will explore the binary system, which is considered a formal fundamental topic in computer engineering technology. Objectives: • To understand binary representation, binary counting, and binary addition. • To understand and perform binary conversions between decimal and binary bases. • To understand the application of binary representation to computer memory systems. Instructions: Follow the procedures below and record all work and answers in your lab notebook. Show your notebook to the instructor when finished to receive completion credit for this lab. Procedure: Part 1: Binary Representation Binary numbers, in principle, work the same way as in decimal except that the digit weights are powers of 2 instead of powers of 10. Consider the number 1,234. Using positional notation, this represents: 1𝑥103 + 2𝑥102 + 3𝑥101 + 4𝑥100 = 1𝑥1000 + 2𝑥100 + 3𝑥10 + 4𝑥1 = 1000 + 200 + 30 + 4 = 1234 Now consider the binary number 1011012. Notice that we’ve introduced the subscript 2 to make it perfectly clear we are referring to a binary number and not decimal 101,101. This is standard practice: no subscript on a number means it is base 10 (decimal) while any other base must be indicated with a subscript after the number. Remember this on exams! This binary number represents: 1𝑥25 + 0𝑥24 + 1𝑥23 + 1𝑥22 + 0𝑥21 + 1𝑥20 = 1𝑥𝟑𝟐 + 0𝑥𝟏𝟔 + 1𝑥𝟖 + 1𝑥𝟒 + 0𝑥𝟐 + 1𝑥𝟏 = 32 + 8 + 4 + 1 = 45 Note that the result, 45, is a decimal number because no subscript is given (but could optionally be given as 10). Observations: • Binary numbers require many more bits to represent the equivalent decimal number because the weights grow much more slowly in binary (1,2,4,8,16,32,64…) than in decimal (1,10,100,1000…) 1 GET130 Intro to Engineering Technology Lab 5: CET • The right-most bit, aka the least-significant bit (lsb), will produce an odd decimal result if 1 and an even decimal result if 0. This is because the lsb carries a weight of 20 or 1. Furthermore, the weight of the rightmost digit of an integer number in any base is always 1. (Why is this so?) • A shortcut to the binary-to-decimal conversion process is to simply “sum the weights where the 1s appear”. 1. What decimal values do the following numbers represent? a. 11112 = ________ b. 1000102 = ________ c. 101001012 = ________ 2. Check the odd/even property of each of the above problems. Part 2: Binary Addition Binary addition, in principle, also works the same way as in decimal except that only 0 and 1 results are valid. An easy way to remember this is consider 1 in binary sort of like 9 in decimal – what comes after 9? Zero! And you increment the next higher position by one. Notice the patterns when counting in binary: 0, 1, 102, 112, 1002, 1012, 1102, 1112, 10002, 10012, 10102, 10112, 11002, 11012, 11102, 11112, 100002 … Adding binary numbers is straight-forward as long as you remember that you can’t exceed 1 in any positional column of the numbers. Ex: 1 1001002 = 36 +0101102 = +22 1110102 = 58 Notice the carry operation and that only 0s and 1s exist in the result. Also note the side conversion to decimal of the addend, augend, and sum for verification purposes. 3. Perform the following binary additions. a. 11112 +01102 b. 1012 c. +101112 101101112 +111000102 4. “Side-convert” each binary number in step 3 to decimal and verify for correct sums. 2 GET130 Intro to Engineering Technology Lab 5: CET Part 3: Binary/Decimal Conversions Converting numeric values between binary and decimal is not only possible, but quite straight-forward. We have already performed binary-to-decimal conversions in part 1 above. Review the 3rd observation bullet in part 1 as this is a speedy, shortcut to binary conversions. Ex. 11011002 = 64 + 32 + 8 + 4 = 108 Of course it helps to know the powers of two, which are easily derived after reviewing a powers-of-2 table. 5. Convert the following binary numbers to decimal using the “sum the weights” shortcut. a. 11112 = ________ b. 1000102 = ________ c. 101001012 = ________ d. 1011001110012 = ________ Conversions in the opposite direction from decimal-to-binary are slightly more complex but still straight-forward using the following recipe: Successively divide the decimal integer by the target base (2) until result = 0; the binary answer is the remainder digits, lsb first. Ex: convert 58 to binary. 58 ÷ 2 = 29, R 0 29 ÷ 2 = 14, R 1 14 ÷ 2 = 7, R 0 7 ÷ 2 = 3, R 1 3 ÷ 2 = 1, R 1 1 ÷ 2 = 0, R 1 So, 5810 = 1110102 Notice how the lsb (0) was the first remainder produced. 6. Convert the following numbers to binary. a. 35 = ____________ b. 100 = ____________ c. 274 = ____________ d. 777 = ____________ As you have previously seen, use of tools in engineering and technology areas is common practice. The TI-89 calculator has base conversion capability via its “EE Pro” app, typically included with the calculator. Another tool you have previously used is Excel. Excel also has built-in functions to do base conversions. With number base conversions being such a common problem in technical areas, we even have on-line tools specifically built for solving such problems. Try this base converter, written in “PHP”, to verify your answers to step 6. 3 GET130 Intro to Engineering Technology Lab 5: CET Part 4: Computer Memory Systems The effects of the binary system are readily seen in sizing computer memory systems. The base unit of computer memory is the byte, which is always 8 bits regardless of platform architecture, manufacturer, etc. As if that weren’t interesting enough, ½ of a byte (8 bits) is called a nibble. Obviously, a single byte of memory cannot store very much, so many many bytes of memory are needed, even to store the smallest of computer programs. It is more common to refer to memory capacity in terms of kilobytes, megabytes, or even gigabytes. The same can be said about capacities of computer hard disk drives with the addition of terabytes. However, the kilo in kilobytes is not what you may think it is, 103. In a computer context it is actually 210 or 1024. Thus, in addition to the engineering notation use of kilo, we also have a computer notation version! As shown in figure 1, you can see the comparison between decimal engineering notation and binary engineering notation. Decimal Value Prefix 3 1 10 = 1000 kilo, k 6 2 10 = 1000 mega, M 9 3 10 = 1000 giga, G 12 4 10 = 1000 tera, T 15 5 10 = 1000 peta, P 18 6 10 = 1000 exa, E 21 7 10 = 1000 zetta, Z 24 8 10 = 1000 yotta, Y Base 2 10 2 20 2 30 2 40 2 50 2 60 2 70 2 80 2 Binary Base 1024 1 1024 2 1024 3 1024 4 1024 5 1024 6 1024 7 1024 8 1024 IEC Prefix kibi, Ki mebi, Mi gibi, Gi tebi, Ti pebi, Pi exbi, Ei zebi, Zi yobi, Yi Fig. 1: Prefix notation comparison For many years, we used the prefixes (kilo, mega, …) to mean either 1000 or 1024, depending on the context. This was the cause of much confusion during this time. For example, hard drive manufacturers would sell you a 500 GB hard drive – meaning 500 x 109 bytes of capacity. Then, after you installed the drive and the operating system formatted it, you discovered you had only 465.6 GB of actual capacity. This is because your computer uses binary sizing or 10243 for GB. This all changed by 2008 when the International Standards Organization (ISO) and International Electrotechnical Commission (IEC) groups clarified this by adopting “binary versions” of the customary prefixes. So, the 500 GB hard drive you installed formats to 465.6 GiB capacity, which signifies the binary version. 7. Solve the following problems. a. A new Macbook is sold with 8 GiB of RAM. How many actual bytes of memory exist? _____________ b. A new 32 GB USB flash drive is inserted into a PC. What (binary) capacity will the computer report for this drive? ______________ c. A Windows 10 PC reports its hard drive as having 931.323 GiB capacity. What is likely to be this drive’s actual decimal capacity? __________ Part 5: Further Study Check the available Apps in your TI-89 for EE Pro and try the conversions in step 6 using your calculator. Find an Internet resource to learn about using Excel for number base conversions. 4