# The OR opertor doubt

Karu Raj

Ranch Hand

Posts: 481

Karu Raj

Ranch Hand

Posts: 481

anand phulwani

Ranch Hand

Posts: 242

posted 10 years ago

To Convert any decimal number into binary

we can folow these steps

Lets Do it With An Exammple

decimal 22 into binary

make a table like this

1

2

4

8

16

32

64

..

..

..

if u wanna convert 22 look for the number or the number just smaller than this,so what i see that the table does not have 22 so the number next smaller than this is 16,write 1 in front of it

1

2

4

8

16--1

32

64

..

..

..

ok next step reduce 16 from the number 22,22-16=6

now we get the number 6 repeat the same procedure,we do not have 6 in the table but do have 4, write 1 in front of it

1

2

4 --1

8

16--1

32

64

..

..

..

now the repeat the same deduct 4 out of 6 ,6-4=2 you got 2 which is in the table,write 1 in front of it

1

2 --1

4 --1

8

16--1

32

64

..

..

..

now when u deduct you 0,2-2=0 so ur binary is complete

now to the remaining table numbers put a 0 in front of it

1 --0

2 --1

4 --1

8 --0

16--1

32

64

..

..

..

now just read the number from down to up,10110 here is your binary conversion

hope you understand this easily

we can folow these steps

Lets Do it With An Exammple

decimal 22 into binary

make a table like this

1

2

4

8

16

32

64

..

..

..

if u wanna convert 22 look for the number or the number just smaller than this,so what i see that the table does not have 22 so the number next smaller than this is 16,write 1 in front of it

1

2

4

8

16--1

32

64

..

..

..

ok next step reduce 16 from the number 22,22-16=6

now we get the number 6 repeat the same procedure,we do not have 6 in the table but do have 4, write 1 in front of it

1

2

4 --1

8

16--1

32

64

..

..

..

now the repeat the same deduct 4 out of 6 ,6-4=2 you got 2 which is in the table,write 1 in front of it

1

2 --1

4 --1

8

16--1

32

64

..

..

..

now when u deduct you 0,2-2=0 so ur binary is complete

now to the remaining table numbers put a 0 in front of it

1 --0

2 --1

4 --1

8 --0

16--1

32

64

..

..

..

now just read the number from down to up,10110 here is your binary conversion

hope you understand this easily

Thanks and Regards, Anand

SCJP 5.0 310-055 73%, SCWCD 1.4 310-081 78%, IBM DB2 9 Fundamentals 000-730 62%

agrah upadhyay

Ranch Hand

Posts: 579