4 ms·
Similar things are relevant for calculations with integers (like array indexes), if you haven‘t yet, read this classic post about it: https://ai.googleblog.com/
by fhars 8y ago
Similar things are relevant for calculations with integers (like array indexes), if you haven‘t yet, read this classic post about it: https://ai.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html?m=1 https://ai.googleblog.com/2006/06/extra-extra-read-all-about... (reader mode makes it accessible on iPhones, why don‘t people test their layouts with common browsers?).
- Sean1708 8y agoIn C and C++ (where you don't have the >>> operator), you can do this: 6: mid = ((unsigned int)low + (unsigned int)high)) >> 1; Since you're casting to unsigned int anyway, can't you just use / 2?
- kevinventullo 8y agoYeah, I believe those compile to the same thing for unsigned ints. You can confirm using godbolt.