Re:What every compiler writer should know about programmers ...
by adwn on Friday March 04, 2016 @03:47AM
(#11222702)
> Wouldn't it be faster to remove that costly ternary conditional operator by zeroing out the first bit?
No, that wouldn't work for two's-complement numbers [1], only for sign-magnitude numbers (like IEEE floating-point numbers). For example, the value -2 is stored as 11111110 (in an 8-bit signed integer); setting the most significant bit to 0 would result in 01111110, or 126 in decimal.
Wouldn't it be faster to remove that costly ternary conditional operator by zeroing out the first bit? Well, there's one degenerate case, for minvalue of int, but that is degenerate either way.