peterolson / BigInteger.js

An arbitrary length integer library for Javascript
The Unlicense
1.12k stars 187 forks source link

32b and 64b constants (or Mersenne fn) #233

Closed Rudxain closed 2 years ago

Rudxain commented 2 years ago

Having constants for the maximum and minimum 32bit and 64bit values is useful, especially for bit-masking, and clamping

peterolson commented 2 years ago

Out of scope for this library. Since this allows integers of arbitrary size, there is nothing particularly special about 32-bit or 64-bit numbers, compared to, say, 128-bit numbers or 256-bit numbers.

These values should be easy enough to define in your own code.

Rudxain commented 2 years ago

What about having a function to generate a n-bit Mersenne number? Doing bigInt.one.shiftLeft(n).prev() or bigInt.minusOne.shiftLeft(n).not() is more cumbersome than bigInt.mersenne(n)

peterolson commented 2 years ago

Fairly niche function and easy enough to implement in userland.

Rudxain commented 2 years ago

Fair enough