S
somenath
Hello All,
I was trying to learn bitwise operator in C .In that process I cam
across one resource as mentioned bellow
http://graphics.stanford.edu/~seander/bithacks.html#OperationCounting
I have one question regarding the section
"Compute the minimum (min) or maximum (max) of two integers without
branching"
In this section author is indicating "if x < y, then -(x < y) will be
all ones" .
My understanding is if negative number is represented in two's
complement method then the above statement is true not for other
representation .
And C standard does not restrict that negative number should be
represented in 2's complement method.
Is my understanding correct?
Please provide some inputs.
Regards,
Somenath
I was trying to learn bitwise operator in C .In that process I cam
across one resource as mentioned bellow
http://graphics.stanford.edu/~seander/bithacks.html#OperationCounting
I have one question regarding the section
"Compute the minimum (min) or maximum (max) of two integers without
branching"
In this section author is indicating "if x < y, then -(x < y) will be
all ones" .
My understanding is if negative number is represented in two's
complement method then the above statement is true not for other
representation .
And C standard does not restrict that negative number should be
represented in 2's complement method.
Is my understanding correct?
Please provide some inputs.
Regards,
Somenath