|
|
|
|
|
by yatac42
1562 days ago
|
|
An important difference between your add method and binary search is that the signature of your add method already implies the contract that the sum of the two integers must fit into an int because there simply is no correct value of the specified return type that could be returned otherwise. There's nothing about the signature of an ordinary binary search method that would imply that it only works for arrays that have less than MAX_INT/2 elements. |
|
Simply put, in many languages there is no addition operator which does mathematically correct addition and that is a sad state of affairs.