int max = ~0;
What does it mean?
The ~ operator is a bit inverse, so ~0 gives you an integer value with all ones (in binary).