-
Notifications
You must be signed in to change notification settings - Fork 39
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
ErrorException: bcmul(): bcmath function argument is not well-formed #159
Comments
@ryanrapini interesting, thanks for the heads up on this; I will take a peak at this later today and see what I can do!
This will depend on what you're converting. Since you are converting a smaller unit to a larger unit, you will wind up with a decimal, so you will to need to pass the $converted_size = $converter->convert('1', 3)->from('mg')->to('g');
echo($converted_size);
0.001 Hopefully that helps! 🙂 P.S. FWIW, the default precision is |
Thanks, this is great help. I dug in a little deeper to the issue before I had to stop working on it - the issue is coming because
the I believe you can force php to output
(from here) but I'm not sure this is the right way to go about this, Hope this helps. |
P.S: your documentation appears to have weird compile errors, FYI https://jordanbrauer.github.io/unit-converter/classes/UnitConverter.UnitConverterInterface.html |
Yeah, not a problem! Thanks for the heads up RE: documentation being out of whack.
What conversion are you performing when this happens? E.g., value and to/from units UnitConverter::default()
->convert($n)
->from($x)
->to($y); You can also get a small debug log that might show more of what's going on with the numbers/formula $converter->getConversionLog(); |
@ryanrapini The issue should be rectified in #163 . If you would like to take advantage of it right away, you can target Here is some samples to show new behaviour working as expected. $bc = new BinaryCalculator(13); // high precision binary calculator
dump(
$bc->add('2.3562e-007', '1.8281e-009'), # (string) 0.0000002374481
$bc->mul('1', '1.0E-6'), # (string) 0.000001
); |
Thanks for your hard work! |
In PHP 7.4 I believe this becomes a warning.
https://www.php.net/manual/en/migration74.incompatible.php
Code to reproduce:
Result:
Additionally, I tried using the standard UnitConverter::default() but I get weird things like:
Any advice?
The text was updated successfully, but these errors were encountered: