Explain briefly how to calculate binary numbers for using of bitwise operators in Python
Answers
Answer:
Binary number system:
According to mathematics , a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: "0" (zero) and "1" (one).
A single binary digit is called bit.
The binary value of numbers can be calculated by numbers '8 4 2 1'
ex : Binary value of 9 = 1001
as sum of 8 and 1 gives 9 so we keep 1 as value of numbers we are adding and remaining numbers as 0
ex : Binary value of 15 = 1111
as sum og 8,4,2,1 gives 15 so we keep 1 as value of every number in binary value.
ex : Binary value of 27 = ?
To get binary value of this numbers we double the biggest number in the set '8 4 2 1'
Then the numbers are '16 8 4 2 1'
then 27 = 11011
as sum of 16,8,2,1 gives 27 so we keep 1 as value of numbers we are adding and remaining numbers as 0
ex : Binary value of 100 = ?
To get binary value of this numbers we double the biggest number in the set '16 8 4 2 1'
Then the numbers are '32 16 8 4 2 1'
sum of this all digits is 63
so again double set '32 16 8 4 2 1'
Then the numbers are '64 32 16 8 4 2 1'
so the higher number we need to double the last number of set by 2 and ceck whether the sum of numbers gives you correct result
Answer:
Binary number system:
According to mathematics , a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: "0" (zero) and "1" (one).
A single binary digit is called bit.
The binary value of numbers can be calculated by numbers '8 4 2 1'
ex : Binary value of 9 = 1001
as sum of 8 and 1 gives 9 so we keep 1 as value of numbers we are adding and remaining numbers as 0
ex : Binary value of 15 = 1111
as sum og 8,4,2,1 gives 15 so we keep 1 as value of every number in binary value.
ex : Binary value of 27 = ?
To get binary value of this numbers we double the biggest number in the set '8 4 2 1'
Then the numbers are '16 8 4 2 1'
then 27 = 11011
as sum of 16,8,2,1 gives 27 so we keep 1 as value of numbers we are adding and remaining numbers as 0
ex : Binary value of 100 = ?
To get binary value of this numbers we double the biggest number in the set '16 8 4 2 1'
Then the numbers are '32 16 8 4 2 1'
sum of this all digits is 63
so again double set '32 16 8 4 2 1'
Then the numbers are '64 32 16 8 4 2 1'
so the higher number we need to double the last number of set by 2 and ceck whether the sum of numbers gives you correct result