advertisement

Counting binary bits Before practicing worksheet, first we have to understand, what binary number is. Binary number is a set of binary digits. A binary digit had two symbols 0 or 1. It had base 2. 2 indicate that, how many symbols base 2 consists of. Computer uses the binary number to process the data. In computers data is in binary. That means binary data. Before understanding how computer process, first we have to understand, how to convert binary to decimal and decimal to binary. Let we will convert decimal to binary, Decimal =7 Binary is calculated like this, First 7 are divided with 2 and remainder is calculated, this process goes on until 2 is divided with 0. See below example for quicker understanding. 2 | 7 -----------2 | 3 - 1 ---------------- 2 | 1 - 1 ---------------- 0 - 1 Now write binary digits from below to up, to write binary number for decimal 7. Binary number for decimal 7 is 111. Let we will convert binary to decimal, Binary= 111 Position values are= 2,1,0 Decimal value of specific binary digit formulae = (position value) * ( 2 pow (position value) ) Now total value = total of each decimal value of specific binary digit. 7 Counting binary bits 8 Total value = 1 * 2 pow 2 + 1* 2 pow 1 +1 * 2 pow 0 =1*4+1*2+1*1 = 4 +2+1 = 7 Decimal value of binary number 111 is 7. Now let we know how computer process data, for that first understand how two binary numbers are added. Before understanding addition of binary numbers, first we have to understand the Boolean algebra principles. Boolean algebra is for operations on binary digits i.e. 1) Sum operation truth table A B 0 0 1 1 0 1 0 1 (A + B) (AND)(Carry) 0 0 0 1 (A^B) (XOR) (Sum) 0 1 1 0 From the above truth table AND operation generates carry and XOR operation generates sum. These operations can be done with AND and XOR gates to calculate total of two binary numbers. Counting binary bits Let we will take 2-bit binary numbers for calculating addition, 11 (3) + 11 (3) ---------------110 --------------1) Position =0 , Sum (XOR) = 1+1 = 0 , Carry (AND) = 1^1 = 1 2) Position=1 , Sum(XOR) =1+1+ 1 (Previous carry) = 1 , Carry (AND)= 1^1^(Previous carry)(1)=1 Now total binary number is 110 (Carry, sum, sum) and decimal value is 6. This total process is calculated through circuits of AND and XOR gates. Similarly many operations can be done through, number of different circuits like OR, NAND, NOR etc. This is a sample example how computer process data. Now I’ am giving binary numbers to count 1s and 0s. 1) Count number of 1s in 11111111000000110000 Answer:- Number of 1 s are _________________ 2) Count number of 0s in 11111111000000110000 Answer:- Number of 0 s are _________________ 3) Count number of 1s in 000000110000 Answer:- Number of 1 s are _________________ 4) Count number of 0s in 000000110000 Answer:- Number of 0 s are _________________ 9 Counting binary bits 5) Count number of 1s in 11111111000000110000 Answer:- Number of 1 s are _________________ 6) Count number of 0 s and 1 s in 11111111000000110000 Answer:- Number of 0 s are ______ and 1s are _____ 7) Count number of 0 s and 1 s in 000000110000 Answer:- Number of 0 s are ______ and 1s are _____ 8) Count number of 0 s and 1 s in 111000000110000 Answer:- Number of 0 s are ______ and 1s are _____ 9) Count number of 0 s and 1 s in 00110000 Answer:- Number of 0 s are ______ and 1s are _____ 10) Count number of 0 s and 1 s in 111100110000 Answer:- Number of 0 s are ______ and 1s are _____ 10