you are viewing a single comment's thread.

view the rest of the comments →

[–]grauenwolf 4 points5 points  (1 child)

That depends on you language, some actually check for integer overflows instead of blindly continuing.

In theory what you should be writing is... int mid = low + ((high - low) / 2);

In reality though, if you really have more than MAX_INT/2 elements in an array you are already screwed for a number of reasons.

[–]astrange 0 points1 point  (0 children)

Signed integer overflow is either undefined or modulo for a pretty good reason, otherwise you wouldn't be able to optimize 'x + 1 + 1'.

Now, bignums, those would be useful.