Comments (6)
Hi, the only binary export option available right now is BigInteger::toBytes()
, which outputs the number as Big Endian, which may be what you're looking for?
There is currently no support for little endian, and I have no idea what GMP_MSW_FIRST
and GMP_LSW_FIRST
do. Does that stand for Most/Least Signifiant Word? How many bytes is a word? When is it useful?
from math.
Hi,
Actually you are right. I just needed to set the second parameter (signed
) to false
to get it working.
from math.
Glad this is useful to you! Adding an option to control endianness would be nice, though.
from math.
Yes indeed.
I will propose a PR.
I also tried to find other useful GMP functions such as gmp_setbit
or gmp_scan1/gmp_scan0.
I am not sure if such function exist on BCMath side, but it could be nice to add them as wall.
WDYT?
from math.
I'm not against a PR for those, what would you use scan0
/scan1
for, though?
from math.
I needed those method to convert IEEE 754 mantissa/exponent tuples (Spomky-Labs/pki-framework@9d3a37d#diff-1329957db3e8301016690cb1fdcbe53d50611e9cb9ecd5d8c568eb60616c909f).
But the code now looks ugly and non-optimized.
Bit manipulation function would help a lot in this case.
I don't have any other use case in mind, but searching for bits and modify them if something I commonly do when working on crypto libraries (signature, encryption and key conversions).
I will implement the IEEE754 conversion tool here into the CBOR library. At the moment, the library is able to convert the mantissa/exponent into a float/int, but the inversed operation is not yet possible.
from math.
Related Issues (20)
- brick/math method for gmp_invert HOT 8
- The given value ".1200" does not represent a valid number. HOT 2
- Add a changelog HOT 3
- Rounding error on exactlyDividedBy() HOT 2
- Fatal error: Maximum execution time of 30 seconds exceeded HOT 2
- RFC: add `getPrecision` method. HOT 11
- Issue with dividedBy and MultipliedBy? HOT 3
- Feature Request: Implement lisachenko/z-engine HOT 1
- BigComplex HOT 2
- How to accept any scale without rounding HOT 1
- Accept hexadecimal input HOT 1
- Rounding is necessary to represent the result of the operation at this scale. HOT 2
- [0.10.0] behavior change HOT 1
- Please support php8.1 HOT 1
- Implements the Serializable interface, which is deprecated HOT 1
- Rounding bug, or am I just dumb? HOT 4
- Output a BigRational in decimal form with period
- Implement `__debugInfo` magic method HOT 4
- Add some generic number type when you don't know if the result will be `int` or `decimal` HOT 1
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 math.