Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

= (~0); What does it mean? [duplicate]

Tags:

c

Possible Duplicates:
Is it safe to use -1 to set all bits to true?
int max = ~0; What does it mean?

Hello,

I have stumbled upon this piece of code..

size_t temp;
temp = (~0);

Anyone knows what it does?

like image 467
Stefanos Kalantzis Avatar asked Feb 25 '23 05:02

Stefanos Kalantzis


1 Answers

~ is the bitwise not operator, it inverts each bit of the operand. In this case the operand is 0, so every bit is initially 0, and after applying the bitwise not every bit will be 1. The end result is you get a size_t filled with 1 bits.

like image 151
verdesmarald Avatar answered Mar 05 '23 13:03

verdesmarald



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!