michael@0: (function(stdlib, n, heap) { michael@0: "use asm" michael@0: var Int16ArrayView = new stdlib.Int16Array(heap); michael@0: function f(i0, d1) { michael@0: i0 = i0 | 0 michael@0: d1 = +d1 michael@0: var d2 = 1. michael@0: var i3 = 0 michael@0: Int16ArrayView[0] = i0 michael@0: d2 = (.0 / .0) michael@0: switch ((i0 + i0) | 0) { michael@0: case 0: michael@0: d2 = .0 michael@0: break michael@0: }; michael@0: (((i3 - (0 < 0)) >>> ((.0 < -0) + (.0 > .0))) / 0) >> (0 + (((0 + 0) ^ michael@0: (9 > 0)) | 0)) michael@0: } michael@0: })(this, null, new ArrayBuffer(4096)); michael@0: michael@0: (function(stdlib, n, heap) { michael@0: "use asm" michael@0: var Float64ArrayView = new stdlib.Float64Array(heap) michael@0: function f() { michael@0: Float64ArrayView[0] = +(0xffffffff / 0xffffffff >> 0) michael@0: } michael@0: })(this, null, new ArrayBuffer(4096)); michael@0: michael@0: function test0(x) michael@0: { michael@0: return (x >>> 0) % 10; michael@0: } michael@0: assertEq(test0(25), 5); michael@0: assertEq(test0(24), 4); michael@0: assertEq(test0(23), 3); michael@0: assertEq(test0(0), 0); michael@0: assertEq(test0(4294967295), 5); michael@0: michael@0: function test1(x) michael@0: { michael@0: return (x >>> 2) % 10; michael@0: } michael@0: assertEq(test1(25), 6); michael@0: assertEq(test1(24), 6); michael@0: assertEq(test1(23), 5); michael@0: assertEq(test1(4294967295), 3); michael@0: michael@0: function test2(x, y) michael@0: { michael@0: return (x >>> 0) % (y >>> 0); michael@0: } michael@0: assertEq(test2(25, 3), 1); michael@0: assertEq(test2(24, 4), 0); michael@0: assertEq(test2(4294967295, 10), 5); michael@0: assertEq(test2(23, 0), NaN); michael@0: michael@0: function test3() michael@0: { michael@0: "use asm"; michael@0: function f(x, y) michael@0: { michael@0: x = x|0; michael@0: y = y|0; michael@0: var t = 0; michael@0: t = (x % y) > -2; michael@0: return t|0; michael@0: } michael@0: return f; michael@0: } michael@0: assertEq(test3()(4294967290, 4294967295), 1); michael@0: assertEq(test3()(4294967290, 4294967295), 1); michael@0: michael@0: function test4() michael@0: { michael@0: "use asm"; michael@0: function f(x, y) michael@0: { michael@0: x = x|0; michael@0: y = y|0; michael@0: var t = 0; michael@0: t = ((x>>>0) % (y>>>0)) > -2; michael@0: return t|0; michael@0: } michael@0: return f; michael@0: } michael@0: assertEq(test4()(4294967290, 4294967295), 1); michael@0: assertEq(test4()(4294967290, 4294967295), 1); michael@0: michael@0: function test5() michael@0: { michael@0: "use asm"; michael@0: function f(x, y) michael@0: { michael@0: x = x|0; michael@0: y = y|0; michael@0: var t = 0; michael@0: t = ((x>>>0) % (y>>>0)) * 1.01; michael@0: return +t; michael@0: } michael@0: return f; michael@0: } michael@0: assertEq(test5()(4294967290, 4294967295), 4337916962.9); michael@0: assertEq(test5()(4294967290, 4294967295), 4337916962.9); michael@0: michael@0: function test6() michael@0: { michael@0: "use asm"; michael@0: function f(x, y) michael@0: { michael@0: x = x|0; michael@0: y = y|0; michael@0: return ((x>>>1) % (y>>>1))|0; michael@0: } michael@0: return f; michael@0: } michael@0: assertEq(test6()(23847, 7), 1); michael@0: assertEq(test6()(23848, 7), 2); michael@0: michael@0: function test7() michael@0: { michael@0: "use asm"; michael@0: function f(x) michael@0: { michael@0: x = x|0; michael@0: return ((x>>>0) / 8)|0; michael@0: } michael@0: return f; michael@0: } michael@0: assertEq(test7()(23847, 7), 2980); michael@0: assertEq(test7()(23848, 7), 2981); michael@0: michael@0: function test8() michael@0: { michael@0: "use asm"; michael@0: function f(i,j) michael@0: { michael@0: i=i|0;j=j|0; michael@0: return ((i>>>0)/(j>>>0))|0; michael@0: } michael@0: return f; michael@0: } michael@0: assertEq(test8()(2147483647, 0), 0); michael@0: assertEq(test8()(2147483646, 0), 0);