Binary Code Complete Tutorial.

Write 7 in different way   : 

2^0 =  1

2^1 = 2

2^2 = 4


4+2+1 = 7 Here we use base 2 to convert this intiger

Day 10: Binary Numbers | HackerRank



Common binary number

0 = 0

1 = 1

2 = 10

3 = 11

4 = 100

5 = 101

6 = 110

7 = 111

8 = 1000

9 = 1001

10 = 1010

11 = 1011

12 = 1100

13 = 1101

14 = 1110

15 = 1111


Operations :-

Binary

0+0=0

0+1=1

1+0=1

1+1=0


For Example the Binary :-

   6 -> 110

+7 ->  111

---------- 

1101

Verify your answers :-

1*2^0 =1

1*2^2 = 4

1*2^3 = 8

             ----

             13


Two's Compliment

Rule 1 :- Two's complement "Flip the bit add 1"

Rule 2 :- "Extending the sign"


6 -> 110 ]3bits          Now I'm converting the number in 8 bits [00000+110] just add the Zero before the binary number started.

Flip the bits or replace the bits where the 0 replace with 1   :-   11111001

11111001

          +1

--------------



12 -> 1100]4bits    Now I'm Coverting this number in the 8 bits  [00001100]

Replace or flip it :- 11110011

after flipping add with 1

11110011

          +1

--------------

11110100

Comments

Popular posts from this blog

CyberSecurity

VERTICAL SCALING 💋

prisma using in project idx 13.3