Integers in Solidity:
uint256
(uint
is an alias) is a unsigned integer which has:
- minimum value of 0
- maximum value of 2^256-1 = 115792089237316195423570985008687907853269984665640564039457584007913129639935 //78 decimal digits
int256
(int
is an alias) is a signed integer which has:
- minimum value of -2^255 = -57896044618658097711785492504343953926634992332820282019728792003956564819968
- maximum value of 2^255-1 = 57896044618658097711785492504343953926634992332820282019728792003956564819967
For example, in Solidity we could write the following code:
uint8 public constant decimals = 6;
uint256 public constant totalSupply = 1000000*10**uint256(decimals); // 1000000000000
P.S. It is unusual that int
/uint
in Solidity have 256 bits in size, because there are such popular languages as C#/Java that have int
data type with 32 bits in size:
- minimum value of -2^31 = -2147483648
- maximum value of 2^31-1 = 2147483647