~ sign in uint256(0)

What means ~uint256(0)?

In a line like this:

constant MAX =  ~uint256(0);

~ is the “bitwize-not” operator.

In this example, it takes the uint256(0), so 256 times the 0 bits (ie 0x0000000000000000000000000000000000000000000000000000000000000000), and applies not the them. The result is thus 256 times the 1 bits, (ie 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)

And what is it purpose? Why do we need to do this?

uint256 private constant MAX = ~uint256(0);
  uint256 private _tTotal = 1000000000 * 10**18;
  uint256 private _rTotal = (MAX - (MAX % _tTotal));

It’s an easy way to get the maximum number.

I see many contracts in older compiler versions were using uint(-1). It is invalid now. Is it producing the same number with ~uint(0)?

Yes it’s the same number.

For what is this number necessary?

Reflection Total not must be equal of tTotal?