Integers

This data type represents integers. The following table shows various keywords used to declare integer data types:

Keyword

Types

Details

int

Signed integer

int8 to int256, which means that keywords are available from int8 up to int256 in increments of 8, for example, int8, int16, int24.

uint

Unsigned integer

uint8, uint16, ... to uint256, unsigned integer from 8 bits to 256 bits. The usage is dependent on the requirements that how many bits are required to be stored in the variable.

For example, in this code, note that uint is an alias for uint256:

uint256 x;  
uint y;  
uint256 z; 

These types can also be declared with the constant keyword, which means that no storage slot will be reserved by the compiler ...

Get Mastering Blockchain - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.