Fixed potential overflow in midpoint calculation