&~ in a formula.
Solved
Anonymous user
-
[Dal] Posted messages 6205 Registration date Status Contributeur Last intervention -
[Dal] Posted messages 6205 Registration date Status Contributeur 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 réponse
Hello astrocurious,
& and ~ are two bitwise operators in C
http://www.bien-programmer.fr/bits.htm
Dal
& and ~ are two bitwise operators in C
http://www.bien-programmer.fr/bits.htm
Dal
Anonymous user
Thank you very much, DAL, it's very clear on your site!
[Dal]
Posted messages
6205
Registration date
Status
Contributeur
Last intervention
1 108
It's not my site, it's Emmanuel Delahaye's :)