I am converting some legacy Pascal to JavaScript. I need to multiple two 32-bit signed integers.
In the following sample loop some multiplications will cause overflow and will give negative numbers. This is intentional. I need to reproduce the same final number x at the end that matches the legacy system.
How can I do this in JavaScript to achieve the same result?
Here is some sample code:
var x = new Number(some value); // I need this to be a 32-bit signed integer
var y = new Number(some value); // I need this to be a 32-bit signed integer
for (var i=0; i<100; i++) {
x = x * y;
}
return x;