- #1
tmt1
- 234
- 0
"Assume integer variable A holds 60 and variable B holds 13 then:A&B will give 12"
Why is this?
Why is this?
tmt said:"Assume integer variable A holds 60 and variable B holds 13 then:A&B will give 12"
Why is this?
evinda said:Write the binary represetation of $A$ and $B$ and then add them.
For example, the binary representation of $A$ is $0011 1100$.
tmt said:I get 01001001 how is this 12?
Bitwise arithmetic is a type of mathematical operation that is performed on individual bits or binary digits within a number. It involves manipulating these bits using logical operators such as AND, OR, XOR, and NOT to perform various operations.
A&B = 12 means that the result of performing a bitwise AND operation on two integer variables, A and B, is equal to the decimal value of 12.
Integer variables are variables that can store whole numbers without any decimal points. In the context of bitwise arithmetic, they are used to represent binary numbers and perform logical operations on their individual bits.
To perform the bitwise AND operation, you first convert the given numbers into binary form. Then, you compare the corresponding bits from each number and if both are 1, the result will be 1. Otherwise, the result will be 0. For example, A=60 in binary is 111100 and B=13 in binary is 1101. Performing A&B will result in 1100, which is equal to 12 in decimal form.
Bitwise arithmetic is commonly used in low-level programming, such as in embedded systems and device drivers. It allows for efficient manipulation of binary data and can also be used for tasks such as data encryption and compression. Understanding bitwise arithmetic is important for anyone working with computer systems and programming at a low level.