Why does the expression n&1 == 0
always return false
, where n
is an integer?
I want to use bitwise operation to determine whether n
is even. However, it always return false. (The clion also prompted me that it always returns false
).
What's more, it works when I use n&1 != 0
to determine whether n
is odd.
Explanation: The chemical formula of Nitrogen is N but Nitrogen exists in a molecule of two ions hence the chemical symbol of Nitrogen gas is written as N2.
Nitrogen (N2) Nitrogen is a chemical element that has the symbol N and atomic number 7 and atomic mass 14.00674µ. Elemental nitrogen is a colorless, odorless, tasteless and mostly inert diatomic gas at standard conditions, constituting 78% by volume of Earth's atmosphere.
N2 is nitrogen gas and there is chemical bond between two nitrogen atoms. 2N represents just two atoms of nitrogen that are not chemically bonded. Simply put, 2N are two atoms of nitrogen, while N2 is one molecule of nitrogen. Was this answer helpful?
In mathematics, N is the symbol for natural numbers. N is represented as the set of natural numbers. N = 1,2,3,4,5,6,7,8,9,10,….. Learn more here: Mathematical Symbols.
Its because of the operator precedence.
==
has higher precedence than the &
operator, so 1 == 0
gets evaluated first to 0. Then the bit wise AND is performed which ultimately returns false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With