← Back to Course

Lesson 32: Downcasting is the same as modulo 2ⁿ

Practice Questions

Question 1: What is the value of `y` after the following code executes?

uint256 x = 1982347601273451125;
uint24 y = uint24(x);

Question 2: What is the value of `y` after the following code executes?

uint256 x = 556;
uint24 y = uint24(x);

Question 3: What is the value of `y` after the following code executes?

uint32 x = 65536;
uint16 y = uint16(x);

Question 4: What is the value of `y` after the following code executes?

uint256 x = 10**40;
uint32 y = uint32(x);

Question 5: What is the value of `y` after the following code executes?

uint128 x = 72057594037927936;
uint8 y = uint8(x);