node-int64-native icon indicating copy to clipboard operation
node-int64-native copied to clipboard

support for basic arithmetic operations

Open jkryl opened this issue 10 years ago • 1 comments

it would be nice if int64-native supported basic arithmetic operations (add and sub), so that people don't have to implement their own versions of such operations in JS (especially if they can be done so easily in C/C++). Arithmetic brings a problem of distinguishing between signed and unsigned representation of numbers. I have created a patch and made my life easier by treating all int64 numbers as unsigned and let user to determine how he wants to treat the result (i.e. by calling either toUnsignedDecimal() or toSignedDecimal() method), because the internal representation of the number whether it's signed or unsigned remains the same.

If people agree that this would be nice thing to have, I can submit a pull request.

jkryl avatar Apr 15 '14 09:04 jkryl

Sounds reasonable - submit a pull request and I'll take a look at it :)

candu avatar Apr 16 '14 00:04 candu