Tag: math
-
Safe way to calculate the mid in a range
—
Given a range, calculating the mid is a straight forward process. But, there’s a problem with this line. Adding two large positive numbers can result in an overflow, if the sum is more than the max positive number. One way to fix it is to use the following: This’ll prevent the expression from overflowing to…