public static long checkedAdd(long a, long b) {
long result = a + b;
checkNoOverflow((a ^ b) < 0 | (a ^ result) >= 0);
return result;
}
I am interested why boolean logical | is used here. Why not to use conditional short circuited ||?
The first comment in that class:
// NOTE: Whenever both tests are cheap and functional, it's faster to use
// &, | instead of &&, ||
More context: https://stackoverflow.com/a/11412121/869736
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With