100 likes | 339 Views
NUMBER CONVERSIONS. Definitions. Natural Numbers – the number 0 and any number obtained by repeatedly adding 1 to it. Base – Foundational value of a number system, dictating the number of digits and the value of digit positions. Also known as the “radix”.
E N D
Definitions • Natural Numbers – the number 0 and any number obtained by repeatedly adding 1 to it. • Base – Foundational value of a number system, dictating the number of digits and the value of digit positions. Also known as the “radix”. • Digits always begin with 0 and end with 1 less than the base • Examples: • Base 10 (decimal) – 0 through 9 • Base 2 (binary) – 0 and 1
Definitions • Positional Notation – System of expressing numbers in which the digits are arranged in succession; the position of each digit has a place value, and the number is equal to the sum of the products of each digit by its place value. • To find the quantity expressed by a number, the digit in a place is multiplied by the place value, and the numbers added. • Example: in base 10, each place represents a higher power of 10, starting with the 0th power. Thus: 943 = 9 * 102 + 4 * 101 + 3* 100 = 900 + 40 + 3
Binary Numbers • Represent all values in terms of 0s and 1s
Binary Numbers • Place value works in the exact same way in binary, only this time, the base of the power it 2, not 10 (see slide 3) • Thus, instead of the decimal place values 1, 10, 100, …, which are powers of 10, we use powers of 2.
Converting a Binary Number to a Decimal Number • Just like we multiplied the digit by the place value in decimal format (again, slide 3, with the place value as a power of 10), we can also multiply the digits in binary by the place value, using powers of two, and add them up to get the decimal value of a binary number. • Example 101 = (1 * 20)+ (0 * 21)+ (1 * 22) = (1 * 1) + (0 * 2) + (1 * 4) = 1 + 0 + 4 = 5
Converting a Binary Number to a Decimal Number • Example: 11010 = (0 * 20)+ (1 * 21)+ (0 * 22)+ (1 * 23)+ (1 * 24) = 0 + (1 * 2) + 0 + (1 * 8) + (1 * 16) = 2 + 8 + 16 = 26 • Steps: • Start from the rightmost digit • Multiply each digit by an increasing power of 2, starting from 20 and going up to 2(number of digits - 1) • Add them up.
Converting a Decimal Number to a Binary Number • Done by repeated division of the number (quotient) by the base (2). The dividend becomes the next quotient to divide, and the string of remainders becoming the binary number. • Example: Convert 19 to binary • Divide decimal number by base. • Dividend becomes new quotient, and remainder is a digit of the binary representation • Repeat two steps above • Divide until last quotient is zero • To get the binary number, read list of remainders from the bottom, upwards. • Hence 19 in binary is 10011 Divide until last quotient is 0
Converting a Decimal Number to a Binary Number • Example: Convert 463 to binary 463 in binary = 111001111 Divide until last quotient is 0
Summary • There are many ways to convert from one system to another • These are just two of the simpler examples. • Should you find another method that works better for you, indulge! • You could always use these methods to check that your answers with the other methods are correct. • Practice: The “do and do again” instructor. • Conversions become easier and less tedious with practice.