
Solidity Programming Essentials
By :

Integers help in storing numbers in contracts. Solidity provides the following two types of integer:
There are multiple flavors of integers in Solidity for each of these types. Solidity provides the uint8
type to represent an 8-bit unsigned integer and thereon in multiples of 8 till it reaches 256. In short, there can be 32 different declarations of uint
with different multiples of 8, such as uint8
, uint16
, and unit24
, as far as the uint256
bit. Similarly, there are equivalent data types for integers, such as int8
and int16
, up to int256
.
Depending on requirements, an appropriately sized integer should be chosen – for example, when storing values between 0 and 255, uint8
is appropriate, and when storing values between...