menu
manual-midpoint
Prefer midpoint operations that cannot overflow intermediate arithmetic
Dividing the sum of two numeric values computes the sum before reducing it and may overflow.
Instead, you SHOULD call .midpoint() on one operand.
Floating-point midpoint rounding can differ from the expanded arithmetic.
Reported
1function middle(left: uint32, right: uint32): uint32 {2 return (left + right) / 2;3}Accepted
1function middle(left: uint32, right: uint32): uint32 {2 return left.midpoint(right);3}