Comments (3)
Thank you for sharing your ideas!
I started with a mutable wrapper, but I dropped it. It turned out that immutable wrappers have comparable performance, while providing a more JavaScript-friendly API. All of the low-level GMP / MPFR functions are also exposed so those can be used when somebody wants to do advanced optimizations. https://github.com/Daninet/gmp-wasm#advanced-usage. You can even mix the high level wrapper with low level code, by accessing the mpz_t pointer from the wrapper.
"Bit slice" read feature wouldn't be a same as doing a shiftRight() + bitwise and() with a bitmask? I see that GMP has functions for manipulating individual bits, maybe those could be exposed in the wrapper.
I like the idea of byte array I/O. I will try to add it to the next version.
from gmp-wasm.
You could definitely implement bit slicing with shifting and masking. I suppose it might be faster to do all that on the inside and just let me ask for a specific range of bits.
For byte arrays, gmpy gives you a "portable" output with a two byte header. You probably want to be interoperable with that as well as the Java version (no header).
from gmp-wasm.
I added some new Integer functions to version 0.8.2:
setBit(index)
setBits(indices)
clearBit(index)
clearBits(indices)
flipBit(index)
flipBits(indices)
getBit(index)
msbPosition()
sliceBits(start, end) => Works similarly to JS Array.slice(), but on bits. It supports negative offsets.
writeTo(num, offset, bitCount) => Can be used to put an another integer somewhere in the middle of the binary representation
toBuffer(littleEndian = false) => Exports Uint8Array without any extra headers. Sign is not included
toString(radix = 10) has now an optional radix parameter
Uint8Array buffers are also supported by the constructor:
ctx.Integer(ctx.Integer('1234567').toBuffer())
Now it also possible to use create and read strings in arbitrary bases:
ctx.Integer(6).toString(7)
ctx.Integer('110', 2)
from gmp-wasm.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gmp-wasm.