OOPS. Last line should clearly be x^y-y=1 So, it seems to work. Negatives do a 1-s complement and then add 1. Positives don't change. SOunds good to me. --ms On 2013-08-23 16:54, Mike Speciner wrote:
well, let's try that... x = 1 y = 0 x^y = 1 x^y - y = 0
On 2013-08-23 16:45, J.P. Grossman wrote:
(typo: that should read 'absx', not 'negx')
On Fri, Aug 23, 2013 at 4:44 PM, J.P. Grossman <jpg@alum.mit.edu> wrote:
Assuming x is a 32-bit integer, here's one way that uses 3 instructions:
int y = x >> 31; int negx = (x ^ y) - y;
J.P.
On Fri, Aug 23, 2013 at 4:25 PM, Warren D Smith <warren.wds@gmail.com>wrote:
suppose my computer wants |x| but it refuses to perform an "if" statement.
What to do?
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun