The different types of data
Solidity is a statically-typed language; the type of data the variable holds needs to be predefined. All the bits of the variables are assigned to zero by default. 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.
The following are the data types provided by Solidity:
- The most simple data type is
bool
. It can hold eithertrue
orfalse
. uint8
,uint16
,uint24
, up touint256
are used to hold unsigned integers of 8 bits, 16 bits, 24 bits, up to 256 bits, respectively. Similarly,int8
,int16
up toint256
are used to hold signed integers of 8 bits, 16 bits up to 256 bits, respectively.uint
andint
are aliases foruint256
andint256
.ufixed
andfixed
represent fractional numbers.ufixed0x8
,ufixed0x16
up toufixed0x256
are used to hold unsigned fractional numbers of 8 bits, 16 bits up to 256 bits, respectively. Similarly,fixed0x8
,fixed0x16
up...