The boolean expression can be refactored. (Only bit-31 is significant).
But it becomes pretty inscrutable.
(x ^ r)< 0&& (x ^ y)>= 0 becomes
(x ^ r)< 0&& (~(x ^ y))< 0 becomes
((x ^ r)& ~(x ^ y))< 0
Roger
On 02/03/2012 07:12 AM, Florian Weimer wrote:
* Eamonn McManus:
On 3 February 2012 00:11, Florian Weimer<fwei...@bfk.de> wrote:
Would it make sense to replace (x ^ r)< 0&& (x ^ y)>= 0
with (x ^ y ^ r)< 0?
That would not be correct. For example, it would signal overflow for -1 + 1.
Oops. But there has to be a way to implement this using just one
comparison.