Download presentation
Presentation is loading. Please wait.
Published byOwen Haynes Modified over 9 years ago
1
CPS120: Introduction to Computer Science Computer Math: Converting to Decimal
2
9 Decimal is base 10 and has 10 digits: 0,1,2,3,4,5,6,7,8,9 Binary is base 2 and has 2 digits: 0,1 For a number to exist in a given number system, the number system must include those digits. For example: The number 284 only exists in base 9 and higher. Binary
3
Codes Given any positive integer base (RADIX) N, there are N different individual symbols that can be used to write numbers in the system. The value of these symbols range from 0 to N-1 All systems we use in computing are positional systems 495 = 400 + 90 +5
4
Number Systems We use the DECIMAL (10 system Computers use BINARY (2 or some shorthand for it like OCTAL (8 or HEXADECIMAL (16
5
BinaryOctalDecimal 00000 00111 01022 01133 10044 10155 11066 11177 100108 1001119 10101210 16 Power of 2 Number System
6
10 How are digits in bases higher than 10 represented? Base 16: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F Bases Higher than 10
7
Conversions
8
Decimal Equivalents Assuming the bits are unsigned, the decimal value represented by the bits of a byte can be calculated as follows: 1. Number the bits beginning on the right using superscripts beginning with 0 and increasing as you move left Note: 2 0, by definition is 1 2. Use each superscript as an exponent of a power of 2 3. Multiply the value of each bit by its corresponding power of 2 4. Add the products obtained
9
What is the decimal equivalent of the octal number 642? 6 x 8² = 6 x 64 = 384 + 4 x 8¹ = 4 x 8 = 32 + 2 x 8º = 2 x 1 = 2 = 418 in base 10 11 Converting Octal to Decimal
10
What is the decimal equivalent of the hexadecimal number DEF? D x 16² = 13 x 256 = 3328 + E x 16¹ = 14 x 16 = 224 + F x 16º = 15 x 1 = 15 = 3567 in base 10 Remember, base 16 is 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Converting Hexadecimal to Decimal
11
What is the decimal equivalent of the binary number 010110? 1 x 2 6 = 1 x 64 = 64 + 1 x 2 5 = 1 x 32 = 32 + 0 x 2 4 = 0 x 16 = 0 + 1 x 2 3 = 1 x 8 = 8 + 1 x 2 2 = 1 x 4 = 4 + 1 x 2 1 = 1 x 2 = 2 + 0 x 2º = 0 x 1 = 0 = 112 in base 10 13 Converting Binary to Decimal
12
Horner’s Method Another procedure to calculate the decimal equivalent of a binary number Note: This method works with any base Horner’s Method: Step 1: Start with the first digit on the left Step 2: Multiply it by the base Step 3: Add the next digit Step 4: Multiply the sum by the base Step 5: Continue the process until you add the last digit
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.