Skip to content
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

Use bc math #43

Open
mathewrapid opened this issue Apr 20, 2015 · 5 comments
Open

Use bc math #43

mathewrapid opened this issue Apr 20, 2015 · 5 comments
Assignees

Comments

@mathewrapid
Copy link

http://php.net/manual/en/book.bc.php

@triplepoint
Copy link
Member

Yeah, that's probably a good idea. I'll want to do some profiling to make sure we're not slowing things down too much, but I think this is probably an important improvement.

@hipsterjazzbo
Copy link

@triplepoint I've done some benchmarks out of curiosity, and for fewer than ~1,000 operations it seems to not really make a difference — either will take < 1ms. BCMath is a lot slower if you're wanting to do tens of thousands of operations, but we're talking ~20ms vs ~2ms, which seems reasonable to me within the intended purpose of this library.

There is also the issue that BCMath is not included by default with PHP (except on windows for some reason), but I think it seems reasonable to require it in order to be able to get accurate results out and avoid floating-point errors.

If that sounds reasonable to you, I'd be happy to go through and change everything to BCMath.

@soyuka
Copy link
Contributor

soyuka commented Jan 12, 2018

What would it take to enable BCMath if available and the default if not?

@TomA-R
Copy link

TomA-R commented Oct 9, 2022

hey @triplepoint this would be really useful, is this on the roadmap?

@soleson
Copy link

soleson commented Jan 20, 2023

I've created a patch that can be installed via composer-patches. The patch defaults the precision to the value set by php. This was a quick-and-dirty fix, so I'm hoping others can review and improve the efficiency.
php-unit-of-measure-bcmath-support.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants