Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CSE1301 Computer Programming Lecture 33 Supplement: Conversions: Unsigned Binary to Decimal Decimal to Unsigned Binary.

Similar presentations


Presentation on theme: "1 CSE1301 Computer Programming Lecture 33 Supplement: Conversions: Unsigned Binary to Decimal Decimal to Unsigned Binary."— Presentation transcript:

1 1 CSE1301 Computer Programming Lecture 33 Supplement: Conversions: Unsigned Binary to Decimal Decimal to Unsigned Binary

2 2 Converting Decimal to/from Unsigned Binary Analogy: Giving a $69.10 change from largest to smallest denomination: 69.10 = 1  $50 bill + 19.10 19.10 = 1  $10 bill + 9.10 9.10 = 1  $5 bill + 4.10 4.10 = 2  $2 coin + 0.10 0.10 = 1  10c coin

3 3 2 5 2 0 2 1 2 2 2 3 2 4 2 6 2 7 01234567 Converting Decimal to/from Unsigned Binary Bit position. Decimal value.

4 4 1248163264128 01234567 Converting Decimal to/from Unsigned Binary Bit position. Decimal value.

5 5 Unsigned Binary to Decimal Example: Convert the unsigned binary number 10011010 to decimal. 01011001

6 6 Unsigned Binary to Decimal 01011001 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 01234567

7 7 01011001 01234567 6412481632128

8 8 Unsigned Binary to Decimal 01011001 01234567 6412481632128 128 + 16 + 8 + 2 = 154 So, 10011010 in unsigned binary is 154 in decimal.

9 9 Decimal to Unsigned Binary Example: Convert the decimal number 105 to unsigned binary.

10 10 Q. What is the highest power of 2 that is less than or equal to 105? A. 64 1 6412481632 0123456 Next, consider the difference: 105 - 64 = 41 128

11 11 1 Q. What is the highest power of 2 that is less than or equal to 41? A. 32 1 1248163264 0123456 Next, consider the difference: 41 - 32 = 9

12 12 1 Q. What is the highest power of 2 that is less than or equal to 9? A. 8 11 1248163264 0123456 Next, consider the difference: 9 - 8 = 1

13 13 1 Q. What is the highest power of 2 that is less than or equal to 1? A. 1 111 1248163264 0123456 Next, consider the difference: 1 - 1 = 0 Done!

14 14 1 Finally, fill the empty boxes with zeros. 100101 1248163264 0123456 So, 105 decimal is 1101001 in unsigned binary.


Download ppt "1 CSE1301 Computer Programming Lecture 33 Supplement: Conversions: Unsigned Binary to Decimal Decimal to Unsigned Binary."

Similar presentations


Ads by Google