{"ScriptPreparationCode":"var i;\r\nvar r;\r\nvar v = 2**16;\r\n\r\nfunction test1() {\r\n for(i=0; i \u003C 1000; \u002B\u002Bi) {\r\n r = 1.0/Math.sqrt(v);\r\n }\r\n}\r\n\r\nfunction test2() {\r\n for(i=0; i \u003C 1000; \u002B\u002Bi) {\r\n r = Q_rsqrt(v);\r\n }\r\n}\r\n\r\n//Based on the fast inverse square root function\r\n// https://en.wikipedia.org/wiki/Fast_inverse_square_root\r\n// Some original comments preserved for humor value\r\n// Designed to try to mimic the original as closely as possible\r\nfunction Q_rsqrt(number)\r\n{ \r\n var i;\r\n var x2, y;\r\n const threehalfs = 1.5;\r\n \r\n x2 = number * 0.5;\r\n y = number;\r\n //evil floating bit level hacking\r\n var buf = new ArrayBuffer(4);\r\n (new Float32Array(buf))[0] = number;\r\n i = (new Uint32Array(buf))[0];\r\n i = (0x5f3759df - (i \u003E\u003E 1)); //What the fuck?\r\n (new Uint32Array(buf))[0] = i;\r\n y = (new Float32Array(buf))[0];\r\n y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration\r\n// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed\r\n\r\n return y;\r\n}","TestCases":[{"Name":"Reciprocal Math.sqrt","Code":"test1();","IsDeferred":false},{"Name":"Quakes fast inverse sqrt. ","Code":"test2();","IsDeferred":false}]}