What are the different data types?
Solidity is a statically typed language; the type of data a variable holds needs to be predefined. By default, all bits of the variables are assigned to 0. In Solidity, variables are function scoped; that is, a variable declared anywhere within a function will be in scope for the entire function regardless of where it is declared.
Now let's look at the various data types provided by Solidity:
- The most simple data type is
bool. It can hold eithertrueorfalse. uint8,uint16,uint24...uint256are used to hold unsigned integers of 8 bits, 16 bits, 24 bits ... 256 bits, respectively. Similarly,int8,int16...int256are used to hold signed integers of 8 bits, 16 bits ... 256 bits, respectively.uintandintare aliases foruint256andint256. Similar touintandint,ufixedandfixedrepresent fractional numbers.ufixed0x8,ufixed0x16...ufixed0x256are used to hold unsigned fractional numbers of 8 bits, 16 bits ... 256 bits, respectively. Similarly,fixed0x8...