The Self-Taught Computer Scientist


Download 1.48 Mb.
Pdf ko'rish
bet57/147
Sana17.06.2023
Hajmi1.48 Mb.
#1540634
1   ...   53   54   55   56   57   58   59   60   ...   147
Bog'liq
books-library.net-11301817Az7X6

1
4
5
2
Figure 6.1: The place values for the
number 1,452 in base 10
Thousands
10
3
Hundreds
10
2
Tens
10
1
Ones
10
0
1
4
5
2
Figure 6.2: The powers of 10 used in the
place values in base 10


Chapter 6 Math
65
2 * 10 ** 0 = 2 * 1 = 2 
___________
1452
The binary number system works the same way as the decimal system, except there are only two 
digits, 0 and 1, and the place values are powers of 2, instead of powers of 10.
The rightmost place value is 2 to the zero power, which is 1. The next place value is 2 to the first 
power, which is 2. The next place value is 2 to the second power, which is 4 (2 × 2). The next place 
value is 2 to the third power, which is 8 (2 × 2 × 2) (Figure 6.3).
Here is an equation that represents the number 1101 in base 2:
(1 * 2 ** 3) + (1 * 2 ** 2) + (0 * 2 ** 1) 
+ (1 * 2 ** 0) = 
8 + 4 + 0 + 1 = 13
Or:
1 * 2 ** 3 = 1 * 8 = 8 +
1 * 2 ** 2 = 1 * 4 = 4 +
0 * 2 ** 1 = 0 * 2 = 0 +
1 * 2 ** 0 = 1 * 1 = 1 
____
13
As you can see, 1101 in binary is 13 in base 10.
In the decimal system, you count by starting at zero: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. At that point, you 
run out of digits. To represent the next number, as you know, you create 10 by using 2 digits. You 
represent 10 with a 1 followed by a 0.
When you count in binary, you also start with zero.
0
And like the decimal system, the next number is 1.
1
Eights
2
3
Fours
2
2
Twos
2

Download 1.48 Mb.

Do'stlaringiz bilan baham:
1   ...   53   54   55   56   57   58   59   60   ...   147




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling