2021-05-31 05:37:11 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.7.0;
|
|
|
|
|
|
|
|
contract TestIntegers {
|
2021-06-02 05:53:33 +00:00
|
|
|
// Following integer type 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
|
|
|
int8 int1;
|
|
|
|
int16 int2;
|
|
|
|
|
2021-06-02 05:53:33 +00:00
|
|
|
// Integer type variable is stored in the next slot as it needs 32 bytes of storage.
|
2021-05-31 05:37:11 +00:00
|
|
|
int256 int3;
|
|
|
|
|
2021-06-02 05:53:33 +00:00
|
|
|
// Integer type 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
|
|
|
int32 int4;
|
|
|
|
|
|
|
|
// Set variable int1.
|
|
|
|
function setInt1(int8 value) external {
|
|
|
|
int1 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set variable int2.
|
|
|
|
function setInt2(int16 value) external {
|
|
|
|
int2 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set variable int3.
|
|
|
|
function setInt3(int256 value) external {
|
|
|
|
int3 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set variable int4.
|
|
|
|
function setInt4(int32 value) external {
|
|
|
|
int4 = value;
|
|
|
|
}
|
|
|
|
}
|