← Back to Course

Lesson 44: Adding fixed-point numbers with unequal scaling factors

Practice Questions

Question 1: `x` is a fixed-point number with a scaling factor of 1e22. `y` is a fixed-point number with a scaling factor of 1e15. We want to add `x` and `y` and get a fixed-point number with a scaling factor of 1e12. Write the code that accomplishes this.

Question 2: `x` is a fixed-point number with a scaling factor of 1e18. `y` is a fixed-point number with a scaling factor of 1e15. We want to add `x` and `y` and get a fixed-point number with a scaling factor of 1e12. Write the code that accomplishes this.

Question 3: `x` is a fixed-point number with a scaling factor of 1e8. `y` is a fixed-point number with a scaling factor of 1e10. We want to add `x` and `y` and get a fixed-point number with a scaling factor of 1e15. Write the code that accomplishes this.

Question 4: `x` is a fixed-point number with a scaling factor of 1e18. `y` is a fixed-point number with a scaling factor of 1e18. We want to add `x` and `y` and get a fixed-point number with a scaling factor of 1e18. Write the code that accomplishes this.

Question 5: `x` is a fixed-point number with a scaling factor of 1e18. `y` is a fixed-point number with a scaling factor of 1e10. We want to add `x` and `y` and get a fixed-point number with a scaling factor of 1e18. Write the code that accomplishes this.