2021-08-12 09:58:13 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0
|
2021-05-31 05:37:11 +00:00
|
|
|
pragma solidity ^0.7.0;
|
|
|
|
|
|
|
|
contract TestUnsignedIntegers {
|
2021-06-02 05:53:33 +00:00
|
|
|
// Following unsigned integer variables are packed together in a single slot since the combined size is less than 32 bytes.
|
2021-05-31 05:37:11 +00:00
|
|
|
uint8 uint1;
|
|
|
|
uint16 uint2;
|
|
|
|
|
2021-06-02 05:53:33 +00:00
|
|
|
// Unsigned integer variable is stored in the next slot as it needs 32 bytes of storage.
|
2021-05-31 05:37:11 +00:00
|
|
|
uint256 uint3;
|
|
|
|
|
2021-06-02 05:53:33 +00:00
|
|
|
// Unsigned integer variable is stored in the next slot as there is not enough space for it in the previous slot.
|
2021-05-31 05:37:11 +00:00
|
|
|
uint32 uint4;
|
|
|
|
|
|
|
|
// Set variable uint1.
|
|
|
|
function setUint1(uint8 value) external {
|
|
|
|
uint1 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set variable uint2.
|
|
|
|
function setUint2(uint16 value) external {
|
|
|
|
uint2 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set variable uint3.
|
|
|
|
function setUint3(uint256 value) external {
|
|
|
|
uint3 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set variable uint4.
|
|
|
|
function setUint4(uint32 value) external {
|
|
|
|
uint4 = value;
|
|
|
|
}
|
|
|
|
}
|