Closed s1na closed 5 years ago
Wouldn't it be pretty simple to just call .reverse()
on the arrays? IMHO that would be a more readable way to change the order than passing in an extra boolean argument to the toArray
/fromArray
functions.
Also, toArray
and fromArray
are already big-endian, i.e. the most significant digit is the first element in the array.
bigInt(4).toArray(2)
/// {"value":[1,0,0],"isNegative":false}
bigInt.fromArray([1, 0, 0], 2).toString()
/// "4"
Sorry, I mistakenly got that impression from #39 (Note that the array representation is small endian
).
Hello,
We rely heavily on big numbers and are discussing switching to a library that polyfills to native BigInts, and that's how I found your great library.
Internally we mostly use big endian representation and If I'm not mistaken the
toArray
(andfromArray
) methods work with little endian representation. I was wondering if you'd consider adding a flag for this to the relevant methods (or would accept a PR doing this).Thanks