uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 10 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
What is the value of the MAX and _rTotal constants?
I couldn’t understand the MAX constant
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 10 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
What is the value of the MAX and _rTotal constants?
I couldn’t understand the MAX constant
Hi, ~
means bitwise negation
, so ~uint256(0) = 2**256-1
, that is the max value in the type of uint256
, and these are just some mathematical calculations, if you do not know, you can deploy the contract to see the final result:
uint256 public constant MAX = ~uint256(0);
uint256 public constant _tTotal = 10 * 10**6 * 10**9;
uint256 public _rTotal = (MAX - (MAX % _tTotal));
So the results are:
MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935
_tTotal = 10000000000000000
_rTotal = 115792089237316195423570985008687907853269984665640564039457580000000000000000
Where can I check the value of these constants while writing the contract?
for example:
console.log(MAX)
print(MAX)
echo(MAX)
What should I do if I want to see the result as defined as?
I am still in the first hours so I am very inexperienced
what should be in a developer’s bag? Which tools and what are their functions?
You can use console.log
, https://medium.com/nomic-labs-blog/better-solidity-debugging-console-log-is-finally-here-fc66c54f2c4a, but now, this plugin renamed hardhat
thank you so much. Let’s see how the result will be