&~ in a formula.
Solved
Anonymous user
-
[Dal] Posted messages 6122 Registration date Status Contributor Last intervention -
[Dal] Posted messages 6122 Registration date Status Contributor Last intervention -
Hello,
I am constantly looking for ways to optimize my code.
This morning I came across a rather strange formula that I don't understand...
Can you explain to me what this piece of code does:
It’s mainly the "& ~" part that intrigues me, is it an operator?
What does it do?
Thank you for your insights!
Configuration: Windows / Chrome 55.0.2883.87
I am constantly looking for ways to optimize my code.
This morning I came across a rather strange formula that I don't understand...
Can you explain to me what this piece of code does:
int nbr = (sizeof(int) -1) & ~(sizeof(int) -1) ; if (nbr ...) { [...] } It’s mainly the "& ~" part that intrigues me, is it an operator?
What does it do?
Thank you for your insights!
Configuration: Windows / Chrome 55.0.2883.87
1 answer
-
Hello astrocurious,
& and ~ are two bitwise operators in C
http://www.bien-programmer.fr/bits.htm
Dal