non decimal numbers
play

Non-decimal Numbers 1 Non-decimal Numbers We are used to decimal - PowerPoint PPT Presentation

Non-decimal Numbers 1 Non-decimal Numbers We are used to decimal numbers in our daily life. However, digital computers are based entirely on electrical currents being "on" or "off" . If there is a voltage in a certain


  1. Non-decimal Numbers 1

  2. Non-decimal Numbers • We are used to decimal numbers in our daily life. However, digital computers are based entirely on electrical currents being "on" or "off" . If there is a voltage in a certain circuit, then it is considered "on", and if not, it is considered "off". While there are variations in the way this is implemented in computer hardware, the point is that everything in computing is based on the notion that there are only two basic states for a system . • For more complicated systems, computers combine several of these on/off systems, hence all digital computers are based on numbers that are best expressed in powers of two. The result is that there are many instances in which humans refer to computer operations directly in base two, eight, or sixteen , without converting to decimal notation. The most basic of these uses binary notation. 2

  3. Binary Representation • In computing it is common to talk about "bits". By this, we mean a single one of the on/off systems mentioned above. Thus, a bit may be considered to be any logical object that can take on values of zero or one, and no others . • Recall that in binary (base two) representations for numbers we have only two possible single-digit numbers: 0 and 1 . We use the same place value for binary number that we do in the decimal case. Thus the representation for two already is a two-digit number in binary: 10 = 1x2 + 0x1 . Similarly, we can see that a three digit binary number ABC= Ax2 2 + Bx2 1 + Cx2 0 . More particularly, we could count from zero to eight in binary as follows: after 0 we have 1 is 1, 2 is 10, 3 is 11, 4 is 100, 5 is 101, 6 is 110, 7 is 111, 8 is 1000 . • Thus we see that we can represent eight numbers with 3 binary digits, sixteen numbers with four digits, thirty-two with 5 digits, sixty-four with 6 digits, one hundred twenty-eight with seven, and two hundred fifty-six number using 8 binary digits. You can see that the largest block of memory or storage addressable using sixteen bits is 65536. 3

  4. Arbitrary Integer Base • If we look carefully at the above numbers, we can see it as an example of the general rule for representations of number in terms of the integer base b . We could write the number n in the base b using the notation n b . Note that: 0 b = 0 x b 0 , 1 b = 1 x b 0 , 2 b = 2 x b 0 , ... , (b- 1) b = (b-1) x b 0 , 10 b = 1 x b 1 + 0 x b 0 , 11 b = 1 x b 1 + 1 x b 0 , 12 b = 1 x b 1 + 2 x b 0 , ... , 101 b = 1 x b 2 + 0 x b 1 + 1 x b 0 • Such representations are useful in many situations. For example, some situations in which the natural division of numbers is into collections of three bits call for octal notation, that is, base eight. 4

  5. Hexadecimal Notation • It is so common to use hexadecimal notation that it deserves special emphasis. Hexadecimal notation is a base sixteen representation for numbers. Thus, two hexadecimal digits suffice to represent 256 numbers, or eight bits worth of information. Since we do not have enough arabic numerals to make sixteen hexadecimal digits, we use letters instead. Thus in "hex" one counts from zero to sixteen as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10 . • It follows that 30 hex is 48 decimal, A0 hex is 160, and FF is 255. 5

  6. Converting Between Different Bases • The beauty of using a base that is a power of two is that conversion to and from binary becomes very easy. For example, each hex digit can be represented by four binary digits. When converting hex to binary, all we have to do is convert one digit at a time. For example F0 16 = 1111 0000 2 A8E 16 = 1010 1000 1110 2 1B8C 16 = 0001 1011 1000 1100 2 • Each hex digit can simply be replaced in the conversion by its binary representation - the place holding takes care of the rest. (and it is not so easy in base 7!). • This also allows us to regroup digits to convert between e.g. hex and octal. F0 16 = 1111 0000 2 = 11 110 000 2 = 360 8 A8E 16 = 1010 1000 1110 2 = 101 010 001 110 2 = 5216 8 6

  7. HTML Color Specification • Hexadecimal notation could be found everywhere: HTML color specifications, ethernet addresses, file permission masks, and lots of other places. • The way colors are created on a computer screen is by having three monochromatic subelements in each picture element on the screen (pixel): one that flashes red , one green , and one blue . These subelements are so close together that the eye combines them into a single color such as orange or teal. Typically, each subelement can take an intensity value that is an eight-bit binary number: a value from 0 to 255 . These are called the RGB values for the color. 7

  8. HTML Color Specification • We can specify these RGB values in HTML in either of two ways. One way is to call a function that takes decimal numbers for the RGB values. For example, <h1 style="color:RGB(0,0,255)"> would give a blue heading. A second way to specify the same colors is as part of a sixtuple of hex digits that correspond to the RGB values : the first two hex digits are the red value, the second two the green value, and the third pair of digits is the blue value. For example, <h1 style="color:#0000FF"> is the same color as that from the previous specification. • Following is a table of HTML tags together with the text they would put on a page: 8

  9. ICE #8 • What is the decimal representation for the following hexadecimal numbers? • F0 • 9F • 8 • 10 • 101 • What is the decimal representation for the following binary numbers? • 1 • 10 • 101 • 1010 • What is the octal representation for the following binary numbers? • 1 • 10 • 1010 • 10111 • 100100 9

  10. ICE #8 • What is the binary representation for the following octal numbers? • 1 • 10 • 42 • 755 • What is the hexadecimal representation for the following decimal numbers? • 8 • 15 • 16 • 128 • 170 • 255 10

  11. Sources • Notes by Prof. Cooper (http://www.math.wsu.edu/math/kcooper/M300/binarynumbers.ph p, http://www.math.wsu.edu/math/kcooper/M300/colors.php) • Here is a pretty straightforward tutorial you may use https://www.tutorialspoint.com/computer_logical_organization/num ber_system_conversion.htm 11

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend