michael@0: /* michael@0: js> (((-1 >>> 1) + 1) * Math.pow(2, 52 - 30) + 1) & 1 michael@0: 0 michael@0: js> (((-1 >> 1) + 1) * Math.pow(2, 52 - 30) + 1) & 1 michael@0: 1 michael@0: */ michael@0: michael@0: function f(x) { michael@0: if (x >= 0) { michael@0: // if it does not fail, try with lower power of 2. michael@0: return (((x >>> 1) + 1) * 4194304 /* 2 ** (52 - 30) */ + 1) & 1; michael@0: } michael@0: return 2; michael@0: } michael@0: michael@0: assertEq(f(-1 >>> 1), 1); michael@0: assertEq(f(-1 >>> 0), 0); michael@0: assertEq(f(-1 >>> 0), 0);