get-random-values-polypony
Version:
Synchronous randombytes function that works in node, the browser & react-native!
10 lines • 44.9 kB
JavaScript
const test=require("fresh-tape"),long=require("../long.js"),add=long.add,subtract=long.subtract,negate=long.negate,and=long.and,multiply=long.multiply,xor=long.xor,not=long.not,shiftLeft=long.shiftLeft,shiftRight=long.shiftRight,shiftRightUnsigned=long.shiftRightUnsigned,compare=long.compare,isZero=long.isZero,isOdd=long.isOdd,toNumber=long.toNumber,fromInt=long.fromInt,fromNumber=long.fromNumber,lt=long.lt,fromFloat=long.fromFloat,verbose=!0,TMP=fromInt(0,!1);function numbers(array){const result=[];for(let i=0;i<array.length;i+=2)result.push({high:4294967295&array[i],low:4294967295&array[i+1]});return result}// Note that these are in numerical order.
const NUMBERS=numbers([2147483648,0,3078018549,1446306523,4293918719,4294967295,4293918720,0,4294901759,4294967295,4294901760,0,4294967294,4294967295,4294967295,0,4294967295,4278190079,4294967295,4278190080,4294967295,4294901759,4294967295,4294901760,4294967295,4294934527,4294967295,4294934528,4294967295,4294967294,4294967295,4294967295,0,0,0,1,0,2,0,32767,0,32768,0,65535,0,65536,0,16777215,0,16777216,0,1446306523,0,3078018549,0,4294967295,1,0,65535,4294967295,65536,0,1048575,4294967295,1048576,0,1446306523,3078018549,2147483647,4294967295]),ADD_RESULTS=numbers([930534901,1446306523,2146435071,4294967295,3076969973,1446306522,2146435072,0,3076969973,1446306523,4292870143,4294967295,2147418111,4294967295,3077953013,1446306522,4293853183,4294967294,4293853183,4294967295,2147418112,0,3077953013,1446306523,4293853183,4294967295,4293853184,0,4294836223,4294967295,2147483646,4294967295,3078018548,1446306522,4293918718,4294967294,4293918718,4294967295,4294901758,4294967294,4294901758,4294967295,2147483647,0,3078018548,1446306523,4293918718,4294967295,4293918719,0,4294901758,4294967295,4294901759,0,4294967293,4294967295,2147483647,4278190079,3078018549,1429529306,4293918719,4278190078,4293918719,4278190079,4294901759,4278190078,4294901759,4278190079,4294967294,4278190078,4294967294,4278190079,2147483647,4278190080,3078018549,1429529307,4293918719,4278190079,4293918719,4278190080,4294901759,4278190079,4294901759,4278190080,4294967294,4278190079,4294967294,4278190080,4294967295,4261412863,2147483647,4294901759,3078018549,1446240986,4293918719,4294901758,4293918719,4294901759,4294901759,4294901758,4294901759,4294901759,4294967294,4294901758,4294967294,4294901759,4294967295,4278124542,4294967295,4278124543,2147483647,4294901760,3078018549,1446240987,4293918719,4294901759,4293918719,4294901760,4294901759,4294901759,4294901759,4294901760,4294967294,4294901759,4294967294,4294901760,4294967295,4278124543,4294967295,4278124544,4294967295,4294836223,2147483647,4294934527,3078018549,1446273754,4293918719,4294934526,4293918719,4294934527,4294901759,4294934526,4294901759,4294934527,4294967294,4294934526,4294967294,4294934527,4294967295,4278157310,4294967295,4278157311,4294967295,4294868990,4294967295,4294868991,2147483647,4294934528,3078018549,1446273755,4293918719,4294934527,4293918719,4294934528,4294901759,4294934527,4294901759,4294934528,4294967294,4294934527,4294967294,4294934528,4294967295,4278157311,4294967295,4278157312,4294967295,4294868991,4294967295,4294868992,4294967295,4294901759,2147483647,4294967294,3078018549,1446306521,4293918719,4294967293,4293918719,4294967294,4294901759,4294967293,4294901759,4294967294,4294967294,4294967293,4294967294,4294967294,4294967295,4278190077,4294967295,4278190078,4294967295,4294901757,4294967295,4294901758,4294967295,4294934525,4294967295,4294934526,2147483647,4294967295,3078018549,1446306522,4293918719,4294967294,4293918719,4294967295,4294901759,4294967294,4294901759,4294967295,4294967294,4294967294,4294967294,4294967295,4294967295,4278190078,4294967295,4278190079,4294967295,4294901758,4294967295,4294901759,4294967295,4294934526,4294967295,4294934527,4294967295,4294967293,2147483648,0,3078018549,1446306523,4293918719,4294967295,4293918720,0,4294901759,4294967295,4294901760,0,4294967294,4294967295,4294967295,0,4294967295,4278190079,4294967295,4278190080,4294967295,4294901759,4294967295,4294901760,4294967295,4294934527,4294967295,4294934528,4294967295,4294967294,4294967295,4294967295,2147483648,1,3078018549,1446306524,4293918720,0,4293918720,1,4294901760,0,4294901760,1,4294967295,0,4294967295,1,4294967295,4278190080,4294967295,4278190081,4294967295,4294901760,4294967295,4294901761,4294967295,4294934528,4294967295,4294934529,4294967295,4294967295,0,0,0,1,2147483648,2,3078018549,1446306525,4293918720,1,4293918720,2,4294901760,1,4294901760,2,4294967295,1,4294967295,2,4294967295,4278190081,4294967295,4278190082,4294967295,4294901761,4294967295,4294901762,4294967295,4294934529,4294967295,4294934530,0,0,0,1,0,2,0,3,2147483648,32767,3078018549,1446339290,4293918720,32766,4293918720,32767,4294901760,32766,4294901760,32767,4294967295,32766,4294967295,32767,4294967295,4278222846,4294967295,4278222847,4294967295,4294934526,4294967295,4294934527,4294967295,4294967294,4294967295,4294967295,0,32765,0,32766,0,32767,0,32768,0,32769,2147483648,32768,3078018549,1446339291,4293918720,32767,4293918720,32768,4294901760,32767,4294901760,32768,4294967295,32767,4294967295,32768,4294967295,4278222847,4294967295,4278222848,4294967295,4294934527,4294967295,4294934528,4294967295,4294967295,0,0,0,32766,0,32767,0,32768,0,32769,0,32770,0,65535,2147483648,65535,3078018549,1446372058,4293918720,65534,4293918720,65535,4294901760,65534,4294901760,65535,4294967295,65534,4294967295,65535,4294967295,4278255614,4294967295,4278255615,4294967295,4294967294,4294967295,4294967295,0,32766,0,32767,0,65533,0,65534,0,65535,0,65536,0,65537,0,98302,0,98303,2147483648,65536,3078018549,1446372059,4293918720,65535,4293918720,65536,4294901760,65535,4294901760,65536,4294967295,65535,4294967295,65536,4294967295,4278255615,4294967295,4278255616,4294967295,4294967295,0,0,0,32767,0,32768,0,65534,0,65535,0,65536,0,65537,0,65538,0,98303,0,98304,0,131071,2147483648,16777215,3078018549,1463083738,4293918720,16777214,4293918720,16777215,4294901760,16777214,4294901760,16777215,4294967295,16777214,4294967295,16777215,4294967295,4294967294,4294967295,4294967295,0,16711678,0,16711679,0,16744446,0,16744447,0,16777213,0,16777214,0,16777215,0,16777216,0,16777217,0,16809982,0,16809983,0,16842750,0,16842751,2147483648,16777216,3078018549,1463083739,4293918720,16777215,4293918720,16777216,4294901760,16777215,4294901760,16777216,4294967295,16777215,4294967295,16777216,4294967295,4294967295,0,0,0,16711679,0,16711680,0,16744447,0,16744448,0,16777214,0,16777215,0,16777216,0,16777217,0,16777218,0,16809983,0,16809984,0,16842751,0,16842752,0,33554431,2147483648,1446306523,3078018549,2892613046,4293918720,1446306522,4293918720,1446306523,4294901760,1446306522,4294901760,1446306523,4294967295,1446306522,4294967295,1446306523,0,1429529306,0,1429529307,0,1446240986,0,1446240987,0,1446273754,0,1446273755,0,1446306521,0,1446306522,0,1446306523,0,1446306524,0,1446306525,0,1446339290,0,1446339291,0,1446372058,0,1446372059,0,1463083738,0,1463083739,2147483648,3078018549,3078018550,229357776,4293918720,3078018548,4293918720,3078018549,4294901760,3078018548,4294901760,3078018549,4294967295,3078018548,4294967295,3078018549,0,3061241332,0,3061241333,0,3077953012,0,3077953013,0,3077985780,0,3077985781,0,3078018547,0,3078018548,0,3078018549,0,3078018550,0,3078018551,0,3078051316,0,3078051317,0,3078084084,0,3078084085,0,3094795764,0,3094795765,1,229357776,2147483648,4294967295,3078018550,1446306522,4293918720,4294967294,4293918720,4294967295,4294901760,4294967294,4294901760,4294967295,4294967295,4294967294,4294967295,4294967295,0,4278190078,0,4278190079,0,4294901758,0,4294901759,0,4294934526,0,4294934527,0,4294967293,0,4294967294,0,4294967295,1,0,1,1,1,32766,1,32767,1,65534,1,65535,1,16777214,1,16777215,1,1446306522,1,3078018548,2147483649,0,3078018550,1446306523,4293918720,4294967295,4293918721,0,4294901760,4294967295,4294901761,0,4294967295,4294967295,0,0,0,4278190079,0,4278190080,0,4294901759,0,4294901760,0,4294934527,0,4294934528,0,4294967294,0,4294967295,1,0,1,1,1,2,1,32767,1,32768,1,65535,1,65536,1,16777215,1,16777216,1,1446306523,1,3078018549,1,4294967295,2147549183,4294967295,3078084085,1446306522,4293984255,4294967294,4293984255,4294967295,4294967295,4294967294,4294967295,4294967295,65534,4294967294,65534,4294967295,65535,4278190078,65535,4278190079,65535,4294901758,65535,4294901759,65535,4294934526,65535,4294934527,65535,4294967293,65535,4294967294,65535,4294967295,65536,0,65536,1,65536,32766,65536,32767,65536,65534,65536,65535,65536,16777214,65536,16777215,65536,1446306522,65536,3078018548,65536,4294967294,65536,4294967295,2147549184,0,3078084085,1446306523,4293984255,4294967295,4293984256,0,4294967295,4294967295,0,0,65534,4294967295,65535,0,65535,4278190079,65535,4278190080,65535,4294901759,65535,4294901760,65535,4294934527,65535,4294934528,65535,4294967294,65535,4294967295,65536,0,65536,1,65536,2,65536,32767,65536,32768,65536,65535,65536,65536,65536,16777215,65536,16777216,65536,1446306523,65536,3078018549,65536,4294967295,65537,0,131071,4294967295,2148532223,4294967295,3079067125,1446306522,4294967295,4294967294,4294967295,4294967295,983039,4294967294,983039,4294967295,1048574,4294967294,1048574,4294967295,1048575,4278190078,1048575,4278190079,1048575,4294901758,1048575,4294901759,1048575,4294934526,1048575,4294934527,1048575,4294967293,1048575,4294967294,1048575,4294967295,1048576,0,1048576,1,1048576,32766,1048576,32767,1048576,65534,1048576,65535,1048576,16777214,1048576,16777215,1048576,1446306522,1048576,3078018548,1048576,4294967294,1048576,4294967295,1114111,4294967294,1114111,4294967295,2148532224,0,3079067125,1446306523,4294967295,4294967295,0,0,983039,4294967295,983040,0,1048574,4294967295,1048575,0,1048575,4278190079,1048575,4278190080,1048575,4294901759,1048575,4294901760,1048575,4294934527,1048575,4294934528,1048575,4294967294,1048575,4294967295,1048576,0,1048576,1,1048576,2,1048576,32767,1048576,32768,1048576,65535,1048576,65536,1048576,16777215,1048576,16777216,1048576,1446306523,1048576,3078018549,1048576,4294967295,1048577,0,1114111,4294967295,1114112,0,2097151,4294967295,3593790171,3078018549,229357777,229357776,1445257947,3078018548,1445257947,3078018549,1446240987,3078018548,1446240987,3078018549,1446306522,3078018548,1446306522,3078018549,1446306523,3061241332,1446306523,3061241333,1446306523,3077953012,1446306523,3077953013,1446306523,3077985780,1446306523,3077985781,1446306523,3078018547,1446306523,3078018548,1446306523,3078018549,1446306523,3078018550,1446306523,3078018551,1446306523,3078051316,1446306523,3078051317,1446306523,3078084084,1446306523,3078084085,1446306523,3094795764,1446306523,3094795765,1446306524,229357776,1446306524,1861069802,1446306524,3078018548,1446306524,3078018549,1446372059,3078018548,1446372059,3078018549,1447355099,3078018548,1447355099,3078018549,4294967295,4294967295,930534901,1446306522,2146435071,4294967294,2146435071,4294967295,2147418111,4294967294,2147418111,4294967295,2147483646,4294967294,2147483646,4294967295,2147483647,4278190078,2147483647,4278190079,2147483647,4294901758,2147483647,4294901759,2147483647,4294934526,2147483647,4294934527,2147483647,4294967293,2147483647,4294967294,2147483647,4294967295,2147483648,0,2147483648,1,2147483648,32766,2147483648,32767,2147483648,65534,2147483648,65535,2147483648,16777214,2147483648,16777215,2147483648,1446306522,2147483648,3078018548,2147483648,4294967294,2147483648,4294967295,2147549183,4294967294,2147549183,4294967295,2148532223,4294967294,2148532223,4294967295,3593790171,3078018548]),SUBTRACT_RESULTS=numbers([0,0,3364432394,2848660773,2148532224,1,2148532224,0,2147549184,1,2147549184,0,2147483649,1,2147483649,0,2147483648,16777217,2147483648,16777216,2147483648,65537,2147483648,65536,2147483648,32769,2147483648,32768,2147483648,2,2147483648,1,2147483648,0,2147483647,4294967295,2147483647,4294967294,2147483647,4294934529,2147483647,4294934528,2147483647,4294901761,2147483647,4294901760,2147483647,4278190081,2147483647,4278190080,2147483647,2848660773,2147483647,1216948747,2147483647,1,2147483647,0,2147418112,1,2147418112,0,2146435072,1,2146435072,0,701177124,1216948747,0,1,930534901,1446306523,0,0,3079067125,1446306524,3079067125,1446306523,3078084085,1446306524,3078084085,1446306523,3078018550,1446306524,3078018550,1446306523,3078018549,1463083740,3078018549,1463083739,3078018549,1446372060,3078018549,1446372059,3078018549,1446339292,3078018549,1446339291,3078018549,1446306525,3078018549,1446306524,3078018549,1446306523,3078018549,1446306522,3078018549,1446306521,3078018549,1446273756,3078018549,1446273755,3078018549,1446240988,3078018549,1446240987,3078018549,1429529308,3078018549,1429529307,3078018549,0,3078018548,2663255270,3078018548,1446306524,3078018548,1446306523,3077953013,1446306524,3077953013,1446306523,3076969973,1446306524,3076969973,1446306523,1631712025,2663255270,930534901,1446306524,2146435071,4294967295,1215900170,2848660772,0,0,4294967295,4294967295,4293984256,0,4293984255,4294967295,4293918721,0,4293918720,4294967295,4293918720,16777216,4293918720,16777215,4293918720,65536,4293918720,65535,4293918720,32768,4293918720,32767,4293918720,1,4293918720,0,4293918719,4294967295,4293918719,4294967294,4293918719,4294967293,4293918719,4294934528,4293918719,4294934527,4293918719,4294901760,4293918719,4294901759,4293918719,4278190080,4293918719,4278190079,4293918719,2848660772,4293918719,1216948746,4293918719,0,4293918718,4294967295,4293853184,0,4293853183,4294967295,4292870144,0,4292870143,4294967295,2847612196,1216948746,2146435072,0,2146435072,0,1215900170,2848660773,0,1,0,0,4293984256,1,4293984256,0,4293918721,1,4293918721,0,4293918720,16777217,4293918720,16777216,4293918720,65537,4293918720,65536,4293918720,32769,4293918720,32768,4293918720,2,4293918720,1,4293918720,0,4293918719,4294967295,4293918719,4294967294,4293918719,4294934529,4293918719,4294934528,4293918719,4294901761,4293918719,4294901760,4293918719,4278190081,4293918719,4278190080,4293918719,2848660773,4293918719,1216948747,4293918719,1,4293918719,0,4293853184,1,4293853184,0,4292870144,1,4292870144,0,2847612196,1216948747,2146435072,1,2147418111,4294967295,1216883210,2848660772,983040,0,983039,4294967295,0,0,4294967295,4294967295,4294901761,0,4294901760,4294967295,4294901760,16777216,4294901760,16777215,4294901760,65536,4294901760,65535,4294901760,32768,4294901760,32767,4294901760,1,4294901760,0,4294901759,4294967295,4294901759,4294967294,4294901759,4294967293,4294901759,4294934528,4294901759,4294934527,4294901759,4294901760,4294901759,4294901759,4294901759,4278190080,4294901759,4278190079,4294901759,2848660772,4294901759,1216948746,4294901759,0,4294901758,4294967295,4294836224,0,4294836223,4294967295,4293853184,0,4293853183,4294967295,2848595236,1216948746,2147418112,0,2147418112,0,1216883210,2848660773,983040,1,983040,0,0,1,0,0,4294901761,1,4294901761,0,4294901760,16777217,4294901760,16777216,4294901760,65537,4294901760,65536,4294901760,32769,4294901760,32768,4294901760,2,4294901760,1,4294901760,0,4294901759,4294967295,4294901759,4294967294,4294901759,4294934529,4294901759,4294934528,4294901759,4294901761,4294901759,4294901760,4294901759,4278190081,4294901759,4278190080,4294901759,2848660773,4294901759,1216948747,4294901759,1,4294901759,0,4294836224,1,4294836224,0,4293853184,1,4293853184,0,2848595236,1216948747,2147418112,1,2147483646,4294967295,1216948745,2848660772,1048575,0,1048574,4294967295,65535,0,65534,4294967295,0,0,4294967295,4294967295,4294967295,16777216,4294967295,16777215,4294967295,65536,4294967295,65535,4294967295,32768,4294967295,32767,4294967295,1,4294967295,0,4294967294,4294967295,4294967294,4294967294,4294967294,4294967293,4294967294,4294934528,4294967294,4294934527,4294967294,4294901760,4294967294,4294901759,4294967294,4278190080,4294967294,4278190079,4294967294,2848660772,4294967294,1216948746,4294967294,0,4294967293,4294967295,4294901759,0,4294901758,4294967295,4293918719,0,4293918718,4294967295,2848660771,1216948746,2147483647,0,2147483647,0,1216948745,2848660773,1048575,1,1048575,0,65535,1,65535,0,0,1,0,0,4294967295,16777217,4294967295,16777216,4294967295,65537,4294967295,65536,4294967295,32769,4294967295,32768,4294967295,2,4294967295,1,4294967295,0,4294967294,4294967295,4294967294,4294967294,4294967294,4294934529,4294967294,4294934528,4294967294,4294901761,4294967294,4294901760,4294967294,4278190081,4294967294,4278190080,4294967294,2848660773,4294967294,1216948747,4294967294,1,4294967294,0,4294901759,1,4294901759,0,4293918719,1,4293918719,0,2848660771,1216948747,2147483647,1,2147483647,4278190079,1216948746,2831883556,1048575,4278190080,1048575,4278190079,65535,4278190080,65535,4278190079,0,4278190080,0,4278190079,0,0,4294967295,4294967295,4294967295,4278255616,4294967295,4278255615,4294967295,4278222848,4294967295,4278222847,4294967295,4278190081,4294967295,4278190080,4294967295,4278190079,4294967295,4278190078,4294967295,4278190077,4294967295,4278157312,4294967295,4278157311,4294967295,4278124544,4294967295,4278124543,4294967295,4261412864,4294967295,4261412863,4294967295,2831883556,4294967295,1200171530,4294967294,4278190080,4294967294,4278190079,4294901759,4278190080,4294901759,4278190079,4293918719,4278190080,4293918719,4278190079,2848660772,1200171530,2147483647,4278190080,2147483647,4278190080,1216948746,2831883557,1048575,4278190081,1048575,4278190080,65535,4278190081,65535,4278190080,0,4278190081,0,4278190080,0,1,0,0,4294967295,4278255617,4294967295,4278255616,4294967295,4278222849,4294967295,4278222848,4294967295,4278190082,4294967295,4278190081,4294967295,4278190080,4294967295,4278190079,4294967295,4278190078,4294967295,4278157313,4294967295,4278157312,4294967295,4278124545,4294967295,4278124544,4294967295,4261412865,4294967295,4261412864,4294967295,2831883557,4294967295,1200171531,4294967294,4278190081,4294967294,4278190080,4294901759,4278190081,4294901759,4278190080,4293918719,4278190081,4293918719,4278190080,2848660772,1200171531,2147483647,4278190081,2147483647,4294901759,1216948746,2848595236,1048575,4294901760,1048575,4294901759,65535,4294901760,65535,4294901759,0,4294901760,0,4294901759,0,16711680,0,16711679,0,0,4294967295,4294967295,4294967295,4294934528,4294967295,4294934527,4294967295,4294901761,4294967295,4294901760,4294967295,4294901759,4294967295,4294901758,4294967295,4294901757,4294967295,4294868992,4294967295,4294868991,4294967295,4294836224,4294967295,4294836223,4294967295,4278124544,4294967295,4278124543,4294967295,2848595236,4294967295,1216883210,4294967294,4294901760,4294967294,4294901759,4294901759,4294901760,4294901759,4294901759,4293918719,4294901760,4293918719,4294901759,2848660772,1216883210,2147483647,4294901760,2147483647,4294901760,1216948746,2848595237,1048575,4294901761,1048575,4294901760,65535,4294901761,65535,4294901760,0,4294901761,0,4294901760,0,16711681,0,16711680,0,1,0,0,4294967295,4294934529,4294967295,4294934528,4294967295,4294901762,4294967295,4294901761,4294967295,4294901760,4294967295,4294901759,4294967295,4294901758,4294967295,4294868993,4294967295,4294868992,4294967295,4294836225,4294967295,4294836224,4294967295,4278124545,4294967295,4278124544,4294967295,2848595237,4294967295,1216883211,4294967294,4294901761,4294967294,4294901760,4294901759,4294901761,4294901759,4294901760,4293918719,4294901761,4293918719,4294901760,2848660772,1216883211,2147483647,4294901761,2147483647,4294934527,1216948746,2848628004,1048575,4294934528,1048575,4294934527,65535,4294934528,65535,4294934527,0,4294934528,0,4294934527,0,16744448,0,16744447,0,32768,0,32767,0,0,4294967295,4294967295,4294967295,4294934529,4294967295,4294934528,4294967295,4294934527,4294967295,4294934526,4294967295,4294934525,4294967295,4294901760,4294967295,4294901759,4294967295,4294868992,4294967295,4294868991,4294967295,4278157312,4294967295,4278157311,4294967295,2848628004,4294967295,1216915978,4294967294,4294934528,4294967294,4294934527,4294901759,4294934528,4294901759,4294934527,4293918719,4294934528,4293918719,4294934527,2848660772,1216915978,2147483647,4294934528,2147483647,4294934528,1216948746,2848628005,1048575,4294934529,1048575,4294934528,65535,4294934529,65535,4294934528,0,4294934529,0,4294934528,0,16744449,0,16744448,0,32769,0,32768,0,1,0,0,4294967295,4294934530,4294967295,4294934529,4294967295,4294934528,4294967295,4294934527,4294967295,4294934526,4294967295,4294901761,4294967295,4294901760,4294967295,4294868993,4294967295,4294868992,4294967295,4278157313,4294967295,4278157312,4294967295,2848628005,4294967295,1216915979,4294967294,4294934529,4294967294,4294934528,4294901759,4294934529,4294901759,4294934528,4293918719,4294934529,4293918719,4294934528,2848660772,1216915979,2147483647,4294934529,2147483647,4294967294,1216948746,2848660771,1048575,4294967295,1048575,4294967294,65535,4294967295,65535,4294967294,0,4294967295,0,4294967294,0,16777215,0,16777214,0,65535,0,65534,0,32767,0,32766,0,0,4294967295,4294967295,4294967295,4294967294,4294967295,4294967293,4294967295,4294967292,4294967295,4294934527,4294967295,4294934526,4294967295,4294901759,4294967295,4294901758,4294967295,4278190079,4294967295,4278190078,4294967295,2848660771,4294967295,1216948745,4294967294,4294967295,4294967294,4294967294,4294901759,4294967295,4294901759,4294967294,4293918719,4294967295,4293918719,4294967294,2848660772,1216948745,2147483647,4294967295,2147483647,4294967295,1216948746,2848660772,1048576,0,1048575,4294967295,65536,0,65535,4294967295,1,0,0,4294967295,0,16777216,0,16777215,0,65536,0,65535,0,32768,0,32767,0,1,0,0,4294967295,4294967295,4294967295,4294967294,4294967295,4294967293,4294967295,4294934528,4294967295,4294934527,4294967295,4294901760,4294967295,4294901759,4294967295,4278190080,4294967295,4278190079,4294967295,2848660772,4294967295,1216948746,4294967295,0,4294967294,4294967295,4294901760,0,4294901759,4294967295,4293918720,0,4293918719,4294967295,2848660772,1216948746,2147483648,0,2147483648,0,1216948746,2848660773,1048576,1,1048576,0,65536,1,65536,0,1,1,1,0,0,16777217,0,16777216,0,65537,0,65536,0,32769,0,32768,0,2,0,1,0,0,4294967295,4294967295,4294967295,4294967294,4294967295,4294934529,4294967295,4294934528,4294967295,4294901761,4294967295,4294901760,4294967295,4278190081,4294967295,4278190080,4294967295,2848660773,4294967295,1216948747,4294967295,1,4294967295,0,4294901760,1,4294901760,0,4293918720,1,4293918720,0,2848660772,1216948747,2147483648,1,2147483648,1,1216948746,2848660774,1048576,2,1048576,1,65536,2,65536,1,1,2,1,1,0,16777218,0,16777217,0,65538,0,65537,0,32770,0,32769,0,3,0,2,0,1,0,0,4294967295,4294967295,4294967295,4294934530,4294967295,4294934529,4294967295,4294901762,4294967295,4294901761,4294967295,4278190082,4294967295,4278190081,4294967295,2848660774,4294967295,1216948748,4294967295,2,4294967295,1,4294901760,2,4294901760,1,4293918720,2,4293918720,1,2848660772,1216948748,2147483648,2,2147483648,2,1216948746,2848660775,1048576,3,1048576,2,65536,3,65536,2,1,3,1,2,0,16777219,0,16777218,0,65539,0,65538,0,32771,0,32770,0,4,0,3,0,2,0,1,0,0,4294967295,4294934531,4294967295,4294934530,4294967295,4294901763,4294967295,4294901762,4294967295,4278190083,4294967295,4278190082,4294967295,2848660775,4294967295,1216948749,4294967295,3,4294967295,2,4294901760,3,4294901760,2,4293918720,3,4293918720,2,2848660772,1216948749,2147483648,3,2147483648,32767,1216948746,2848693540,1048576,32768,1048576,32767,65536,32768,65536,32767,1,32768,1,32767,0,16809984,0,16809983,0,98304,0,98303,0,65536,0,65535,0,32769,0,32768,0,32767,0,32766,0,32765,0,0,4294967295,4294967295,4294967295,4294934528,4294967295,4294934527,4294967295,4278222848,4294967295,4278222847,4294967295,2848693540,4294967295,1216981514,4294967295,32768,4294967295,32767,4294901760,32768,4294901760,32767,4293918720,32768,4293918720,32767,2848660772,1216981514,2147483648,32768,2147483648,32768,1216948746,2848693541,1048576,32769,1048576,32768,65536,32769,65536,32768,1,32769,1,32768,0,16809985,0,16809984,0,98305,0,98304,0,65537,0,65536,0,32770,0,32769,0,32768,0,32767,0,32766,0,1,0,0,4294967295,4294934529,4294967295,4294934528,4294967295,4278222849,4294967295,4278222848,4294967295,2848693541,4294967295,1216981515,4294967295,32769,4294967295,32768,4294901760,32769,4294901760,32768,4293918720,32769,4293918720,32768,2848660772,1216981515,2147483648,32769,2147483648,65535,1216948746,2848726308,1048576,65536,1048576,65535,65536,65536,65536,65535,1,65536,1,65535,0,16842752,0,16842751,0,131072,0,131071,0,98304,0,98303,0,65537,0,65536,0,65535,0,65534,0,65533,0,32768,0,32767,0,0,4294967295,4294967295,4294967295,4278255616,4294967295,4278255615,4294967295,2848726308,4294967295,1217014282,4294967295,65536,4294967295,65535,4294901760,65536,4294901760,65535,4293918720,65536,4293918720,65535,2848660772,1217014282,2147483648,65536,2147483648,65536,1216948746,2848726309,1048576,65537,1048576,65536,65536,65537,65536,65536,1,65537,1,65536,0,16842753,0,16842752,0,131073,0,131072,0,98305,0,98304,0,65538,0,65537,0,65536,0,65535,0,65534,0,32769,0,32768,0,1,0,0,4294967295,4278255617,4294967295,4278255616,4294967295,2848726309,4294967295,1217014283,4294967295,65537,4294967295,65536,4294901760,65537,4294901760,65536,4293918720,65537,4293918720,65536,2848660772,1217014283,2147483648,65537,2147483648,16777215,1216948746,2865437988,1048576,16777216,1048576,16777215,65536,16777216,65536,16777215,1,16777216,1,16777215,0,33554432,0,33554431,0,16842752,0,16842751,0,16809984,0,16809983,0,16777217,0,16777216,0,16777215,0,16777214,0,16777213,0,16744448,0,16744447,0,16711680,0,16711679,0,0,4294967295,4294967295,4294967295,2865437988,4294967295,1233725962,4294967295,16777216,4294967295,16777215,4294901760,16777216,4294901760,16777215,4293918720,16777216,4293918720,16777215,2848660772,1233725962,2147483648,16777216,2147483648,16777216,1216948746,2865437989,1048576,16777217,1048576,16777216,65536,16777217,65536,16777216,1,16777217,1,16777216,0,33554433,0,33554432,0,16842753,0,16842752,0,16809985,0,16809984,0,16777218,0,16777217,0,16777216,0,16777215,0,16777214,0,16744449,0,16744448,0,16711681,0,16711680,0,1,0,0,4294967295,2865437989,4294967295,1233725963,4294967295,16777217,4294967295,16777216,4294901760,16777217,4294901760,16777216,4293918720,16777217,4293918720,16777216,2848660772,1233725963,2147483648,16777217,2147483648,1446306523,1216948747,0,1048576,1446306524,1048576,1446306523,65536,1446306524,65536,1446306523,1,1446306524,1,1446306523,0,1463083740,0,1463083739,0,1446372060,0,1446372059,0,1446339292,0,1446339291,0,1446306525,0,1446306524,0,1446306523,0,1446306522,0,1446306521,0,1446273756,0,1446273755,0,1446240988,0,1446240987,0,1429529308,0,1429529307,0,0,4294967295,2663255270,4294967295,1446306524,4294967295,1446306523,4294901760,1446306524,4294901760,1446306523,4293918720,1446306524,4293918720,1446306523,2848660772,2663255270,2147483648,1446306524,2147483648,3078018549,1216948747,1631712026,1048576,3078018550,1048576,3078018549,65536,3078018550,65536,3078018549,1,3078018550,1,3078018549,0,3094795766,0,3094795765,0,3078084086,0,3078084085,0,3078051318,0,3078051317,0,3078018551,0,3078018550,0,3078018549,0,3078018548,0,3078018547,0,3077985782,0,3077985781,0,3077953014,0,3077953013,0,3061241334,0,3061241333,0,1631712026,0,0,4294967295,3078018550,4294967295,3078018549,4294901760,3078018550,4294901760,3078018549,4293918720,3078018550,4293918720,3078018549,2848660773,0,2147483648,3078018550,2147483648,4294967295,1216948747,2848660772,1048577,0,1048576,4294967295,65537,0,65536,4294967295,2,0,1,4294967295,1,16777216,1,16777215,1,65536,1,65535,1,32768,1,32767,1,1,1,0,0,4294967295,0,4294967294,0,4294967293,0,4294934528,0,4294934527,0,4294901760,0,4294901759,0,4278190080,0,4278190079,0,2848660772,0,1216948746,0,0,4294967295,4294967295,4294901761,0,4294901760,4294967295,4293918721,0,4293918720,4294967295,2848660773,1216948746,2147483649,0,2147483649,0,1216948747,2848660773,1048577,1,1048577,0,65537,1,65537,0,2,1,2,0,1,16777217,1,16777216,1,65537,1,65536,1,32769,1,32768,1,2,1,1,1,0,0,4294967295,0,4294967294,0,4294934529,0,4294934528,0,4294901761,0,4294901760,0,4278190081,0,4278190080,0,2848660773,0,1216948747,0,1,0,0,4294901761,1,4294901761,0,4293918721,1,4293918721,0,2848660773,1216948747,2147483649,1,2147549183,4294967295,1217014282,2848660772,1114112,0,1114111,4294967295,131072,0,131071,4294967295,65537,0,65536,4294967295,65536,16777216,65536,16777215,65536,65536,65536,65535,65536,32768,65536,32767,65536,1,65536,0,65535,4294967295,65535,4294967294,65535,4294967293,65535,4294934528,65535,4294934527,65535,4294901760,65535,4294901759,65535,4278190080,65535,4278190079,65535,2848660772,65535,1216948746,65535,0,65534,4294967295,0,0,4294967295,4294967295,4293984256,0,4293984255,4294967295,2848726308,1216948746,2147549184,0,2147549184,0,1217014282,2848660773,1114112,1,1114112,0,131072,1,131072,0,65537,1,65537,0,65536,16777217,65536,16777216,65536,65537,65536,65536,65536,32769,65536,32768,65536,2,65536,1,65536,0,65535,4294967295,65535,4294967294,65535,4294934529,65535,4294934528,65535,4294901761,65535,4294901760,65535,4278190081,65535,4278190080,65535,2848660773,65535,1216948747,65535,1,65535,0,0,1,0,0,4293984256,1,4293984256,0,2848726308,1216948747,2147549184,1,2148532223,4294967295,1217997322,2848660772,2097152,0,2097151,4294967295,1114112,0,1114111,4294967295,1048577,0,1048576,4294967295,1048576,16777216,1048576,16777215,1048576,65536,1048576,65535,1048576,32768,1048576,32767,1048576,1,1048576,0,1048575,4294967295,1048575,4294967294,1048575,4294967293,1048575,4294934528,1048575,4294934527,1048575,4294901760,1048575,4294901759,1048575,4278190080,1048575,4278190079,1048575,2848660772,1048575,1216948746,1048575,0,1048574,4294967295,983040,0,983039,4294967295,0,0,4294967295,4294967295,2849709348,1216948746,2148532224,0,2148532224,0,1217997322,2848660773,2097152,1,2097152,0,1114112,1,1114112,0,1048577,1,1048577,0,1048576,16777217,1048576,16777216,1048576,65537,1048576,65536,1048576,32769,1048576,32768,1048576,2,1048576,1,1048576,0,1048575,4294967295,1048575,4294967294,1048575,4294934529,1048575,4294934528,1048575,4294901761,1048575,4294901760,1048575,4278190081,1048575,4278190080,1048575,2848660773,1048575,1216948747,1048575,1,1048575,0,983040,1,983040,0,0,1,0,0,2849709348,1216948747,2148532224,1,3593790171,3078018549,2663255270,1631712026,1447355099,3078018550,1447355099,3078018549,1446372059,3078018550,1446372059,3078018549,1446306524,3078018550,1446306524,3078018549,1446306523,3094795766,1446306523,3094795765,1446306523,3078084086,1446306523,3078084085,1446306523,3078051318,1446306523,3078051317,1446306523,3078018551,1446306523,3078018550,1446306523,3078018549,1446306523,3078018548,1446306523,3078018547,1446306523,3077985782,1446306523,3077985781,1446306523,3077953014,1446306523,3077953013,1446306523,3061241334,1446306523,3061241333,1446306523,1631712026,1446306523,0,1446306522,3078018550,1446306522,3078018549,1446240987,3078018550,1446240987,3078018549,1445257947,3078018550,1445257947,3078018549,0,0,3593790171,3078018550,4294967295,4294967295,3364432394,2848660772,2148532224,0,2148532223,4294967295,2147549184,0,2147549183,4294967295,2147483649,0,2147483648,4294967295,2147483648,16777216,2147483648,16777215,2147483648,65536,2147483648,65535,2147483648,32768,2147483648,32767,2147483648,1,2147483648,0,2147483647,4294967295,2147483647,4294967294,2147483647,4294967293,2147483647,4294934528,2147483647,4294934527,2147483647,4294901760,2147483647,4294901759,2147483647,4278190080,2147483647,4278190079,2147483647,2848660772,2147483647,1216948746,2147483647,0,2147483646,4294967295,2147418112,0,2147418111,4294967295,2146435072,0,2146435071,4294967295,701177124,1216948746,0,0]),MULTIPLY_RESULTS=numbers([2147483648,0,2147483648,0,450439690,2848660773,0,0,3528458240,0,1048576,0,2147483648,0,1705912842,2848660773,1114112,1,1048576,0,0,0,488964096,0,65536,0,0,0,65536,0,2147483648,0,4065609519,2848660773,1048577,1,1048576,0,65537,1,65536,0,0,0,2848660773,0,1,0,0,0,1,0,0,0,1,0,2147483648,0,1395848487,3469417765,1048576,16777217,1048576,0,65536,16777217,65536,0,16777217,16777217,16777217,0,0,0,178899741,620756992,0,16777216,0,0,0,16777216,0,0,16777216,16777216,16777216,0,65536,16777216,2147483648,0,1922290645,3337624869,1048576,65537,1048576,0,65536,65537,65536,0,65537,65537,65537,0,256,16842753,256,16777216,0,0,705341899,488964096,0,65536,0,0,0,65536,0,0,65536,65536,65536,0,256,65536,256,0,1,65536,2147483648,0,3717103344,945659173,1048576,32769,1048576,0,2147549184,32769,2147549184,0,32769,32769,32769,0,128,16809985,128,16777216,0,2147581953,0,2147549184,0,0,2500154597,2391965696,0,32768,0,0,2147483648,32768,2147483648,0,32768,32768,32768,0,128,32768,128,0,0,2147516416,0,2147483648,0,1073774592,0,0,2433897493,1402354250,2097152,2,2097152,0,131072,2,131072,0,2,2,2,0,0,33554434,0,33554432,0,131074,0,131072,0,65538,0,65536,2147483648,0,1216948746,2848660773,1048576,1,1048576,0,65536,1,65536,0,1,1,1,0,0,16777217,0,16777216,0,65537,0,65536,0,32769,0,32768,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147483648,0,3078018549,1446306523,4293918719,4294967295,4293918720,0,4294901759,4294967295,4294901760,0,4294967294,4294967295,4294967295,0,4294967295,4278190079,4294967295,4278190080,4294967295,4294901759,4294967295,4294901760,4294967295,4294934527,4294967295,4294934528,4294967295,4294967294,4294967295,4294967295,0,0,0,0,1861069802,2892613046,4292870143,4294967294,4292870144,0,4294836223,4294967294,4294836224,0,4294967293,4294967294,4294967294,0,4294967295,4261412862,4294967295,4261412864,4294967295,4294836222,4294967295,4294836224,4294967295,4294901758,4294967295,4294901760,4294967295,4294967292,4294967295,4294967294,0,0,0,2,2147483648,0,3011761445,456695077,1048575,4294934529,1048576,0,2147549183,4294934529,2147549184,0,4294934528,4294934529,4294934529,0,4294967168,16744449,4294967168,16777216,4294967295,2147516417,4294967295,2147549184,4294967295,3221225473,4294967295,3221258240,4294967295,4294901762,4294967295,4294934529,0,0,0,32767,0,65534,0,0,1794812698,1903001600,4294967295,4294934528,0,0,2147483647,4294934528,2147483648,0,4294934527,4294934528,4294934528,0,4294967167,4294934528,4294967168,0,4294967295,2147450880,4294967295,2147483648,4294967295,3221192704,4294967295,3221225472,4294967295,4294901760,4294967295,4294934528,0,0,0,32768,0,65536,0,1073709056,2147483648,0,511606847,2359696677,1048575,4294901761,1048576,0,65535,4294901761,65536,0,4294901760,4294901761,4294901761,0,4294967040,16711681,4294967040,16777216,4294967295,1,4294967295,65536,4294967295,2147450881,4294967295,2147516416,4294967295,4294836226,4294967295,4294901761,0,0,0,65535,0,131070,0,2147385345,0,2147450880,0,0,3589625396,3806003200,4294967295,4294901760,0,0,4294967295,4294901760,0,0,4294901759,4294901760,4294901760,0,4294967039,4294901760,4294967040,0,4294967294,4294901760,4294967295,0,4294967295,2147418112,4294967295,2147483648,4294967295,4294836224,4294967295,4294901760,0,0,0,65536,0,131072,0,2147418112,0,2147483648,0,4294901760,2147483648,0,1038049005,2227903781,1048575,4278190081,1048576,0,65535,4278190081,65536,0,4278190080,4278190081,4278190081,0,4294901760,1,4294901760,16777216,4294967039,4278255617,4294967040,65536,4294967167,4278222849,4294967168,32768,4294967295,4261412866,4294967295,4278190081,0,0,0,16777215,0,33554430,127,4278157313,127,4294934528,255,4278124545,255,4294901760,0,0,4116067554,3674210304,4294967295,4278190080,0,0,4294967295,4278190080,0,0,4278190079,4278190080,4278190080,0,4294901759,4278190080,4294901760,0,4294967039,4278190080,4294967040,0,4294967167,4278190080,4294967168,0,4294967295,4261412864,4294967295,4278190080,0,0,0,16777216,0,33554432,127,4278190080,128,0,255,4278190080,256,0,65535,4278190080,2147483648,0,3159811567,369059673,3528458239,2848660773,3528458240,0,488964095,2848660773,488964096,0,2848660772,2848660773,2848660773,0,4289317660,3469417765,4289317661,620756992,4294945226,3337624869,4294945227,488964096,4294956261,945659173,4294956261,2391965696,4294967295,1402354250,4294967295,2848660773,0,0,0,1446306523,0,2892613046,11034,456695077,11034,1903001600,22068,2359696677,22068,3806003200,5649634,2227903781,5649634,3674210304,2147483648,0,1953853200,2672775831,2695888895,1216948747,2695888896,0,705363967,1216948747,705363968,0,1216948746,1216948747,1216948747,0,4282943785,1401498123,4282943786,184549376,4294920328,1922312715,4294920329,705363968,4294943811,3717114379,4294943812,2500165632,4294967294,2433897494,4294967295,1216948747,0,0,0,3078018549,1,1861069802,23482,3011750411,23483,1794801664,46966,511584779,46966,3589603328,12023509,1032399371,12023509,4110417920,1036505751,2672775831,2147483648,0,2663255269,2848660773,1048575,1,1048576,0,65535,1,65536,0,0,1,1,0,4278190079,16777217,4278190080,16777216,4294901759,65537,4294901760,65536,4294934527,32769,4294934528,32768,4294967294,2,4294967295,1,0,0,0,4294967295,1,4294967294,32766,4294934529,32767,4294934528,65534,4294901761,65535,4294901760,16777214,4278190081,16777215,4278190080,1446306522,2848660773,3078018548,1216948747,0,0,1446306523,0,4294967295,0,0,0,4294967295,0,0,0,4294967295,0,0,0,4278190079,0,4278190080,0,4294901759,0,4294901760,0,4294934527,0,4294934528,0,4294967294,0,4294967295,0,0,0,1,0,2,0,32767,0,32768,0,65535,0,65536,0,16777215,0,16777216,0,1446306523,0,3078018549,0,4294967295,0,2147483648,0,727984650,2848660773,983040,1,1048576,0,0,1,65536,0,4294901761,1,1,0,4294901760,16777217,0,16777216,4294901760,65537,0,65536,2147418112,32769,2147483648,32768,4294836224,2,4294901760,1,0,0,65535,4294967295,131071,4294967294,2147418111,4294934529,2147483647,4294934528,4294901759,4294901761,4294967295,4294901760,4294901759,4278190081,4294967295,4278190080,3806003199,2848660773,3589603327,1216948747,4294901759,1,4294967295,0,0,0,3806003200,0,4294901760,0,0,0,4294901760,0,0,0,4294901760,0,0,0,4294901760,0,0,0,4294901760,0,0,0,2147418112,0,2147483648,0,4294836224,0,4294901760,0,0,0,65536,0,131072,0,2147418112,0,2147483648,0,4294901760,0,0,0,4294901760,0,0,0,3806003200,0,3589603328,0,4294901760,0,0,0,4294901760,0,2147483648,0,1983457802,2848660773,0,1,1048576,0,4293984256,1,65536,0,4293918721,1,1,0,4293918720,16777217,0,16777216,4293918720,65537,0,65536,4293918720,32769,0,32768,4292870144,2,4293918720,1,0,0,1048575,4294967295,2097151,4294967294,4293918719,4294934529,4294967295,4294934528,4293918719,4294901761,4294967295,4294901760,4293918719,4278190081,4294967295,4278190080,766509055,2848660773,1599078399,1216948747,4293918719,1,4294967295,0,4293853184,1,4294901760,0,0,0,766509056,0,4293918720,0,0,0,4293918720,0,0,0,4293918720,0,0,0,4293918720,0,0,0,4293918720,0,0,0,4293918720,0,0,0,4292870144,0,4293918720,0,0,0,1048576,0,2097152,0,4293918720,0,0,0,4293918720,0,0,0,4293918720,0,0,0,766509056,0,1599078400,0,4293918720,0,0,0,4293918720,0,0,0,4293918720,0,2147483648,0,2322912873,2672775831,1249582372,1216948747,2695888896,0,3554024740,1216948747,705363968,0,4065609519,1216948747,1216948747,0,3457394254,1401498123,608733482,184549376,3337577901,1922312715,488917129,705363968,945635688,3717114379,2391942212,2500165632,1402354248,2433897494,2848660772,1216948747,0,0,1446306523,3078018549,2892613047,1861069802,456718559,3011750411,1903025083,1794801664,2359743643,511584779,3806050166,3589603328,2239927290,1032399371,3686233813,4110417920,1405565424,2672775831,583692197,917347449,1631712025,1216948747,3078018549,0,2143296804,1216948747,3589603328,0,152771876,1216948747,1599078400,0,2147483648,0,3364432394,2848660773,2148532224,1,1048576,0,2147549184,1,65536,0,2147483649,1,1,0,2147483648,16777217,0,16777216,2147483648,65537,0,65536,2147483648,32769,0,32768,0,2,2147483648,1,0,0,2147483647,4294967295,4294967295,4294967294,2147483647,4294934529,4294967295,4294934528,2147483647,4294901761,4294967295,4294901760,2147483647,4278190081,4294967295,4278190080,2147483647,2848660773,2147483647,1216948747,2147483647,1,4294967295,0,2147418112,1,4294901760,0,2146435072,1,4293918720,0,701177124,1216948747]);function toStr(long){return verbose&&"{low:"+long.low+",high:"+long.high+"}"}// Here and below, we translate one conceptual test (e.g., "testComparisons")
// into a number of test functions that will be run separately by jsunit. This
// is necessary because, in some testing configurations, the full combined test
// can take so long that it times out. These smaller tests run much faster.
test("negate",function(t){const negInt=function(num,unsigned){return negate(fromInt(num,unsigned),TMP,unsigned)};t.deepEquals(negInt(1),fromInt(-1),verbose&&"negate(1)"),t.deepEquals(negInt(-1),fromInt(1),verbose&&"negate(-1)"),t.deepEquals(function(low,high,unsigned){return negate({low:low,high:high},TMP,unsigned)}(1446306523,-1216948747,!1),{low:-1446306523,high:1216948746}),t.end()}),test("is*",function(t){const result={},expected={};NUMBERS.forEach(function(long){const longStr=toStr(long);result[longStr]={isZero:isZero(long),isOdd:isOdd(long)},expected[longStr]={isZero:0===long.low&&0===long.high,isOdd:0!=(1&long.low)}}),t.deepEquals(result,expected,"is* operations"),t.end()}),test("compare",function(t){for(let i=0;i<NUMBERS.length;i++){const longI=NUMBERS[i],result={},expected={};for(let j=0;j<NUMBERS.length;j++){const longJ=NUMBERS[j],longJStr=toStr(longJ);result[longJStr]={compare:compare(longI,longJ,!1),lt:lt(longI,longJ,!1)},expected[longJStr]={compare:i===j?0:i<j?-1:1,lt:i<j}}t.deepEquals(result,expected,verbose&&"compare/lt("+toStr(longI))}t.end()}),test("bit operations",function(t){function shiftOps(long,len,shiftExpected){const key="shift("+len+")";result[key]={shiftLeft:shiftLeft(long,len,{}),shiftRight:shiftRight(long,len,{}),shiftRightUnsigned:shiftRightUnsigned(long,len,{})},expected[key]=shiftExpected}let result,expected;NUMBERS.forEach(function(long){result={not:not(long,TMP)},expected={not:{low:~long.low,high:~long.high}};const longStr=toStr(long);NUMBERS.forEach(function(other){const otherStr=toStr(other);// result['| ' + otherStr] = or(long, other, {})
result["& "+otherStr]=and(long,other,{}),expected["& "+otherStr]={low:long.low&other.low,high:long.high&other.high},result["^ "+otherStr]=xor(long,other,{}),expected["^ "+otherStr]={low:long.low^other.low,high:long.high^other.high}}),shiftOps(long,0,{shiftLeft:long,shiftRight:long,shiftRightUnsigned:long});for(let len=1;64>len;++len)shiftOps(long,len,32>len?{shiftLeft:{high:long.high<<len|long.low>>>32-len,low:long.low<<len},shiftRight:{high:long.high>>len,low:long.low>>>len|long.high<<32-len},shiftRightUnsigned:{high:long.high>>>len,low:long.low>>>len|long.high<<32-len}}:{shiftLeft:{high:long.low<<len-32,low:0},shiftRight:{high:0<=long.high?0:-1,low:long.high>>len-32},shiftRightUnsigned:{high:0,low:32===len?long.high:long.high>>>len-32}});shiftOps(long,64,{shiftLeft:long,shiftRight:long,shiftRightUnsigned:long}),t.deepEquals(result,expected,verbose&&"shift operations for "+longStr)}),t.end()}),test("to number",function(t){// TODO: edge cases
t.equals(toNumber({low:0,high:1},!1),4294967296,verbose&&"toNumber({low: 0, high: 1}, false)"),t.equals(toNumber({low:2,high:2},!1),8589934594,verbose&&"toNumber({low: 0, high: 1}, false)"),t.equals(toNumber({low:16777215,high:0},!1),16777215,verbose&&"toNumber({low: 0, high: 1}, false)"),t.equals(toNumber({low:0,high:-65536},!1),-281474976710656,verbose&&"toNumber({low: 0, high: 1}, false)"),t.end()}),test("add, subtract, multiply",function(t){let count=0;for(var i=0;i<NUMBERS.length;i++){const long=NUMBERS[i],longStr=toStr(long),result={},expected={};for(var j=0;j<i;j++){const other=NUMBERS[j],otherStr=toStr(other);result[otherStr]={add:add(long,other,{low:0,high:0}),multiply:multiply(long,other,{low:0,high:0},!1)},expected[otherStr]={add:ADD_RESULTS[count],multiply:MULTIPLY_RESULTS[count]},count++}t.deepEquals(result,expected,verbose&&"#"+i+" add/multiply("+longStr+", x, false)")}t.end()}),test("subtract",function(t){let count=0;for(var i=0;i<NUMBERS.length;i++){const long=NUMBERS[i],longStr=toStr(long),result={},expected={};NUMBERS.forEach(function(other){const otherStr=toStr(other);result[otherStr]=subtract(long,other,{low:0,high:0},!1),expected[otherStr]=SUBTRACT_RESULTS[count],count++}),t.deepEquals(result,expected,verbose&&"#"+i+" subtract("+longStr+", x, false)")}t.end()}),test("from number",function(t){// TODO: edge cases
t.deepEquals(fromNumber(1,TMP,!1),{low:1,high:0},verbose&&"fromNumber(1, false)"),t.deepEquals(fromNumber(-1,TMP,!1),{low:-1,high:-1},verbose&&"fromNumber(-1, false)"),t.deepEquals(fromNumber(1,TMP,!0),{low:1,high:0},verbose&&"fromNumber(1, true)"),t.deepEquals(fromNumber(-1,TMP,!0),{low:0,high:0},verbose&&"fromNumber(-1, true)"),t.deepEquals(fromNumber(-47223662013946685e5,{},!1),{low:0,high:-2147483648},verbose&&"from(-4.7223662013946685e+21, false)"),t.deepEquals(fromNumber(.5,TMP,!0),{low:0,high:0},verbose&&"floating points get dropped"),t.end()}),test("from float",function(t){// TODO: edge cases
t.deepEquals(fromFloat(.5,TMP),{low:0,high:1071644672},verbose&&"fromFloats(0.5, 0)"),t.deepEquals(fromFloat(123131415.1123415,TMP),{low:1551042982,high:1100831576},verbose&&"fromFloats(123131415.1123415, 123.1131)"),t.deepEquals(fromFloat(-.5,TMP),{low:0,high:3219128320},verbose&&"fromFloats(-0.5, 0)"),t.end()});