Comments by "Anony Mousse" (@anon_y_mousse) on "Computerphile"
channel.
-
6
-
5
-
4
-
4
-
4
-
3
-
2
-
2
-
2
-
2
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
@SimonVaIe The issue isn't whether to do a signed or unsigned shift right, but in the adding of two numbers when the allocation is near the boundary of available memory. When the addition of l and r causes an overflow, ( l + r ) / 2 will yield an incorrect value. One suggested solution is to use a larger integer type, such as 64-bit integers, but it's still recommended that you write your code in a type agnostic and portable way. Since the calculation in question will only run log(N) times, just quit trying to optimize yourself into a failure state and do it correctly from the start. And in case you weren't aware, every single compiler I've tested this on, will optimize n / 2 into n >> 1, or in Java parlance, n >>> 1, even at an optimization level of -O0. Check with Compiler Explorer if you don't believe it.
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1