Comments (5)
Hi!
Thanks for reaching out. First of all congrats for your library, I've never stumbled upon it before, it really handles advanced (for me, at least!) mathematical concepts.
Indeed if you add arbitrary size integer/decimal support, our libraries will overlap somehow on this point, which is not really a problem but may lead to duplicate efforts. brick/math
's objective is to only provide the arbitrary size objects (integer/decimal/rational), and nothing more (but do it well).
This is particularly useful for anything related to money.
One of the strengths of brick/math is its ability to use GMP or BCMath functions when available, and to fall back to plain PHP when not (with a performance penalty). It may lack more advanced features, but so far there haven't been requests for these features despite > 1M downloads.
I'm afraid I won't have time to invest into translating what I've done here for another project, however if you want to avoid reinventing the wheel, and think that you can build your arbitrary-sized objects on top of brick/math
, then by all means I'll be happy to help, including if this requires changes here (I'm still in 0.x
so quite flexible).
from math.
I'm not the lead developer, I just submit a lot of code. One of the main points is to be free of dependencies, so no references to GMP, or BCMath in this project. These large numbers can then be used for things like cryptographic functions or matrix algebra. Just thought I'd let you know about the project in case you need some more mathematical objects, or want a place to put some code you've developed.
from math.
One of the main points is to be free of dependencies, so no references to GMP, or BCMath in this project.
I'm not sure whether this is a good move, TBH. I call them optional dependencies in brick/math
's case, as nothing will tell you that you must install them, and the library will work just fine without them. Only the docs will mention them, so that you know how to make the lib faster if you need the speed.
However, the performance gain by taking advantage of these libraries is HUGE (tenfold at least), so it's not to be taken lightly. You can simply not achieve, or even approach, the same level of performance by using plain PHP. PHP is an interpreted language on top of a state machine, so inherently slower, and does not even give you the low-level bricks you'd need to manipulate data in the way GMP does it, or at least, not in an efficient manner.
Anyway, if you feel like it, just benchmark it to get an idea.
Just thought I'd let you know about the project in case you need some more mathematical objects, or want a place to put some code you've developed.
For now I'm good, but thanks for the suggestion! It's always interesting to see what's around anyway.
from math.
I fully agree with you, but I’m not the lead dev. I’ve been using GMP to guide the design of my object so that down the road an interface can be used internally instead of the object.
from math.
That sounds like a wise approach.
In brick/math
, this is achieved through the Calculator abstract class. It's not an interface, as it contains helper methods, some of which can be overridden by child classes if they natively implement the function (e.g., gcd()
).
Implementations:
- BCMathCalculator
- GmpCalculator
- NativeCalculator (plain PHP)
from math.
Related Issues (20)
- brick/math method for gmp_random_range HOT 4
- 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
- `gmp_export` equivalent HOT 6
- Rounding bug, or am I just dumb? HOT 4
- Output a BigRational in decimal form with period
- Implement `__debugInfo` magic method HOT 4
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.