-
Notifications
You must be signed in to change notification settings - Fork 39
/
Uint.sol
56 lines (47 loc) · 1.08 KB
/
Uint.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract Uint8Test {
uint8 public Uint8;
// gas 22234
function setUint8() external {
Uint8 = 1;
}
// gas 53427
function useUint8() external returns (uint8) {
uint8 selectedRange = 50;
for (uint8 i=0; i < selectedRange; i++) {
Uint8 += 1;
}
return Uint8;
}
}
contract Uint32Test {
uint32 public Uint32;
// gas 22234
function setUint32() external {
Uint32 = 1;
}
// gas 53895
function useUint32() external returns (uint32) {
uint32 selectedRange = 50;
for (uint32 i=0; i < selectedRange; i++) {
Uint32 += 1;
}
return Uint32;
}
}
contract Uint256Test {
uint256 public Uint256;
// gas 22238
function setUint256() external {
Uint256 = 1;
}
// gas 42950
function useUint256() external returns (uint) {
uint selectedRange = 50;
for (uint i=0; i < selectedRange; i++) {
Uint256 += 1;
}
return Uint256;
}
}