I need to do bitwise operations on large numbers.
For example:
2 | 2147483648
I would expect 2147483650
, but instead, get -2147483646
Why is this, and what can I do about it?
Note, the code I am working on is some old javascript code that is run server side in classic asp, which I believe is an older version of js
I found a workaround.
You can use the
BigInteger.js
library with slight modifications for use in server-side JS with Classic ASP.https://raw.githubusercontent.com/peterolson/BigInteger.js/master/BigInteger.js
For use in classic asp, do the following:
Modify line 21 and 28 of the
BigInteger.js
library so it will work server side with classic ASP:Change Line 21:
To:
And make the same change to line 28.
Then, remove the last 4 lines. They are not needed:
Then in your script include it like this:
You can now use the function in the classic ASP vbscript code:
Output will be
2147483650
as expected.