Multiple ChoiceBeginner 45s
std::midpoint overflow safety
Why is std::midpoint(a,b) preferable to (a+b)/2 for large integer values?
Options
- 1It always rounds toward zero for integer arguments unlike the division form
- 2It works on pointers only and is therefore not usable with integer arguments
- 3It is constexpr-unsafe and cannot be evaluated in a constant expression context
- 4It avoids overflow because it does not compute the full sum before dividing
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.