New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does this support scientific notation? #11
Comments
Hi, yes it can parse numbers of any size in scientific notation: use Brick\Math\BigDecimal;
echo BigDecimal::of('1.23456e27'); // 1234560000000000000000000000
echo BigDecimal::of('1.23456789e-31'); // 0.000000000000000000000000000000123456789 It always outputs them in full decimal notation, however, is that OK for your use case? |
I believe by digging around further while trying to simply solve my immediate need, I found some spots in the source where it discusses scientific notation in the BigNumber file. Here's a link to that for those who may look after me: Line 44 in b163583
|
Thanks for the rapid response... here I am 19 hours later, never once thought I should refresh the page haha. I found it quickly. I really like and appreciate your library. I'm doing unit conversions, and was looking into a few of the libraries. I'm intending to marry your library with one or possibly two of those. Thanks for the example that goes even better with the link. :-D |
The reason I'm asking, I'm trying to do some Unit Conversions using the https://github.com/PhpUnitsOfMeasure/php-units-of-measure library, and unfortunately with the accuracy I'm trying to have, the floats they are currently using isn't enough. I'm looking at maybe converting their library to use this library for the numbers. However for the SI Units, it's all notated in scientific notation... which I could manually convert, but why if I don't have to?
Thanks!
The text was updated successfully, but these errors were encountered: