Professional Documents
Culture Documents
Mws Gen Aae Spe Pptbinaryrepresentation
Mws Gen Aae Spe Pptbinaryrepresentation
Mws Gen Aae Spe Pptbinaryrepresentation
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
05/22/24 http://numericalmethods.eng.usf.edu 1
Binary Representation
http://numericalmethods.eng.usf.edu
How a Decimal Number is
Represented
1 2
257.76 2 10 5 10 7 10 7 10 6 10
2 1 0
3 http://numericalmethods.eng.usf.edu
Base 2
(1 23 0 2 2 1 21 1 20 )
(1011.0011) 2 1 2 3 4
( 0 2 0 2 1 2 1 2 ) 10
11 .1875
4 http://numericalmethods.eng.usf.edu
Convert Base 10 Integer to binary
representation
Table 1 Converting a base-10 integer to binary representation.
Quotient Remainder
11/2 5 1 a0
5/2 2 1 a1
2/2 1 0 a2
1/2 0 1 a3
Hence
(11)10 (a3 a 2 a1 a0 ) 2
(1011) 2
5 http://numericalmethods.eng.usf.edu
Start
Integer N to be
Input (N)10
converted to binary
format
i=0
Divide N by 2 to get
quotient Q & remainder R
i=i+1,N=Q
ai = R
No
Is Q = 0?
Yes
n=i
(N)10 = (an. . .a0)2
STOP
6 http://numericalmethods.eng.usf.edu
Fractional Decimal Number
to Binary
Table 2. Converting a base-10 fraction to binary representation.
Hence
(0.1875)10 (a1a 2 a 3a 4 ) 2
(0.0011) 2
7 http://numericalmethods.eng.usf.edu
Start
Fraction F to be
Input (F)10
converted to binary
format
i 1
Multiply F by 2 to get
number before decimal, S
and after decimal, T
i i 1, F T
ai = R
No
Is T =0?
Yes
n=i
(F)10 = (a-1. . .a-n)2
STOP
8 http://numericalmethods.eng.usf.edu
Decimal Number to Binary
11.187510 ?.? 2
Since
(11)10 (1011) 2
and
(0.1875)10 (0.0011) 2
we have
(11 .1875)10 (1011 .0011) 2
9 http://numericalmethods.eng.usf.edu
All Fractional Decimal Numbers
Cannot be Represented Exactly
Table 3. Converting a base-10 fraction to approximate binary representation.
Number Number
Number after before
decimal Decimal
0 .3 2 0.6 0.6 0 a1
0 .6 2 1.2 0.2 1 a 2
0 .2 2 0.4 0.4 0 a 3
0 .4 2 0.8 0.8 0 a 4
0 .8 2 1.6 0.6 1 a 5
10 http://numericalmethods.eng.usf.edu
Another Way to Look at
Conversion
1 2 0 2 1 2 1 2
3 2 1 0
10112
11 http://numericalmethods.eng.usf.edu
0.187510 2 3
0.0625
2 3 2 4
1 2 3 4
0 2 0 2 1 2 1 2
.00112
http://numericalmethods.eng.usf.edu/topics/
binary_representation.html
THE END
http://numericalmethods.eng.usf.edu