To convert a given numbers to a binary system, we will use the Euclidean algorithm.
(more information: https://en.wikipedia.org/wiki/Euclidean_division)
More specifically, we will divide by 2 and we will be interested in the remainders.
Note : With a separate picture, I will show how this division looks like if you do it "in a column".
1) 479
1 case : 47910→x2
479÷2=239(remainder1)239÷2=119(remainder1)119÷2=59(remainder1)59÷2=29(remainder1)29÷2=14(remainder1)14÷2=7(remainder0)7÷2=3(remainder1)3÷2=1(remainder1)It remains to write down the results obtained: writes down the numbers in reverse order, that is, it starts with the quotient from the last step, and then writes down only the remainders.
Conclusion,
47910→(111011111)2
When converting from a binary number to a decimal number, we do "as if the opposite": we multiply "1" or "0" by "2" to the degree that corresponds to the (position-1) of the specified "0" or "1".
2 case : (111011111)2→x10
(111011111)2=1⋅29−1+1⋅28−1+1⋅27−1+0⋅26−1+1⋅25−1++1⋅24−1+1⋅23−1+1⋅22−1+1⋅21−1==28+27+26+24+0+23+22+21+20==256+128+64+16+8+4+2+1==384+80+15=464+15=479
2) 8735
1 case : 873510→x2
8735÷2=4367(remainder1)4367÷2=2183(remainder1)2183÷2=1091(remainder1)1091÷2=545(remainder1)545÷2=272(remainder1)272÷2=136(remainder0)136÷2=68(remainder0)68÷2=34(remainder0)34÷2=17(remainder0)17÷2=8(remainder1)8÷2=4(remainder0)4÷2=2(remainder0)2÷2=1(remainder0)
Conclison,
873510→(01001000011111)2
Note : the first "0" is not taken into account.
873510→(1001000011111)2
2 case : (1001000011111)2→x10
(1001000011111)2=1⋅213−+1⋅210−1+1⋅25−1++1⋅24−1+1⋅23−1+1⋅22−1+1⋅21−1==213+29+24+23+22+21+20==8192+512+16+8+4+2+1=8735
Comments