long.js
long.js copied to clipboard
Implement power function (clean up)
This is basically a clean up of the previous PR: https://github.com/dcodeIO/long.js/pull/62.
Adds power function. See original PR for previous details and discussion. This also fixes a couple places where multiply could return a signed zero when the original was unsigned (which was mentioned in https://github.com/dcodeIO/long.js/issues/72).
It is probably best not to let that operation silently overflow without throwing some kind of meaningful error. I think I've figured out how to check for overflow in a relatively efficient manner. If there is a cleaner way to go about it, I am open to suggestions.
Looking back at this, I realized I could catch floating point exponents easily enough in the overflow check, so I tweaked it and added the necessary test.