128. Arithmetic Edge Cases-II

Question.7

A firmware engineer writes this before adding two unsigned values:

uint16_t a = sensor_reading;
uint16_t b = offset;

if (a > UINT16_MAX - b) {
   handle_overflow_error();
   return;
}
uint16_t result = a + b;

What technique is this code demonstrating?

Need Help? Refer to the Quick Guide below

Select Answer