Questions? Email sfo.lax6776@gmail.com

Join our weChat group or follow us on Facebook

©2019 by Legion of Learners

sfolax6776
Jul 16, 2018

2.12 - Conversion among binary, octal and hexadecimal numbers

5 comments

Edited: Oct 14

A. Introduction

1 octal digit can be turned into 3 binary digits because 2^3=8.

000[0], 001[1], 010[2], 011[3], 100[4], 101[5], 110[6], 111[7]

1 hexadecimal digit can be mapped with 4 binary digits because 2^4=16

0000[0], 0001[1], 0010[2], 0011[3], 0100[4], 0101[5], 0110[6], 0111[7]

1000[8], 1001[9], 1010[A], 1011[B], 1100[C], 1101[D], 1110[E], 1111[F]

B. Conversion

  1. From Octal / Hex to Binary: replace each digit the corresponding binary digits as above

  2. From Binary to Octal / Hex: starting from the rightmost digit, turn every 3 or 4 digits into the corresponding Octal / Hex digit. Supply leading 0's as necessary.

  3. From Octal to Hex: use Binary as a bridge.

C. Try:

 

 

tian
Jul 18, 2018

1. A6

2. 4DE

3. a) 100010 b) 11010 c) 1011100 d) 1011 e) 10001100; bcd

4. 168C18

5. 10001001111

6. 5

 

rtptyu
Jul 22, 2018

1.0A6

2.4BD

3.

4.168C14

5.11010001111

6.1018

sfolax6776
Jul 23, 2018Edited: Jul 23, 2018

Good work everyone, I know the calculation could be challenge when you switch among different systems. Below are the correct answers for reference.

1. 0A6 or A6

2. 4CE

3. a) 100010 b) 111010 c) 1011100 d) 1011 e) 10001100; bcd

4. 168C14

5. 10001001111

6. A

wangernestrdragon
Jul 23, 2018

1)A6

2)4CE

3)a)100010 b)111010 c)1011100 d)1011 e)10001100----b,c,d

4)168C14

5)10001001111

6)A

mr.ricklu
Jul 23, 2018

1. A6

2. 532 (16) - 64 (16) = 4CE

3. A. 100010 B. 111010 C. 1011100 D. 1011 E. 10001100

Numbers with more 1 than 0: 111010, 1011100, 1011

4. 168C14

5. 10001001111

6. A

New Posts
  • sfolax6776
    7 days ago

    A. Introduction The third and last type of flow is all about repetitions: how to repeat some actions exact N times? or how to repeat some actions until certain status is achieved? There are actually three types of statements: for loops, while loops and do loops. B. Watch( Slides ) C. Try: Print out a multiplication table from 1 x 1 = 1 .... to 9 x 9 = 81. (Hint: you need a for loop inside a for loop)
  • sfolax6776
    Nov 1

    A. Introduction You were asked to use for-loops to print out a multiplication table, for-loops and nested for-loops are widely used for many applications. Here are some examples. B. Watch( Slides ) C. Try to print out the upper half or the lower half of a multiplication table like this:
  • sfolax6776
    Oct 26

    A. Introduction do loops are essentially same at while loops except that they will run at least once. All three types of loops can be converted into each other... Which one to choose? B. Watch( slides ) C. Try this: Write a do loop that reads integers and computes their sum. Stop when reading a zero or the same value twice in a row. For example, if the input is 1 2 3 4 4, then the sum is 14 and the loop stops.