← Back to Course

Lesson 21: Unchecked overflow

Practice Questions

Question 1: What is the value of `z` in the following code?

uint256 z;
uint24 x = 16775592;
uint24 y = 1048576;
unchecked {
      z = x + y;
}

Question 2: What is the value of `z` in the following code?

uint256 z;
uint64 x = 1125899906842624;
uint32 y = 1048576;
unchecked {
      z = x * y;
}

Question 3: What is the value of `z` in the following code?

uint256 z;
uint32 x = 1_000_000;
uint32 y = 1_000_000;
unchecked {
      z = x + y;
}

Question 4: What is the value of `z` in the following code?

uint256 z;
uint64 x = 2 ether;
uint24 y = 10**5;
unchecked {
      z = x * y;
}

Question 5: What is the value of `z` in the following code?

uint256 z;
uint16 x = 1_000;
uint24 y = 1 weeks;
unchecked {
      z = x * y;
}