What’s the meaning of ~0 in this code?
Can somebody analyze this code for me?
unsigned int Order(unsigned int maxPeriod = ~0) const
{
Point r = *this;
unsigned int n = 0;
while( r.x_ != 0 && r.y_ != 0 )
{
++n;
r += *this;
if ( n > maxPeriod ) break;
}
return n;
}
~0is the bitwise complement of0, which is a number with all bits filled. For an unsigned 32-bit int, that’s0xffffffff. The exact number offs will depend on the size of the value that you assign~0to.