You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ composer require fab2s/math
32
32
33
33
### Requirements
34
34
35
-
- PHP 8.1+
35
+
- PHP 8.2+
36
36
- ext-bcmath (required)
37
37
- ext-gmp (optional, faster base conversions, mod, pow and powMod)
38
38
@@ -368,48 +368,48 @@ protected $casts = [
368
368
369
369
## Benchmarks
370
370
371
-
Compared against [brick/math](https://github.com/brick/math) (PHP 8.4, opcache off, GMP enabled). The **bold** value is the faster one in each row, and _Factor_ shows how many times faster it is.
371
+
Compared against [brick/math](https://github.com/brick/math) (PHP 8.5, opcache off, GMP enabled). The **bold** value is the faster one in each row, and _Factor_ shows how many times faster it is.
372
372
373
373
| Operation | fab2s/math | brick/math | Factor |
374
374
|---|---:|---:|---:|
375
-
| instantiate int |**0.261μs (±4.0%)**| 0.301μs (±8.9%) | 1.15x|
All operations above use immutable `Math` (the default). fab2s/math wins every operation except base-16 conversion, where brick/math delegates to GMP's native hex output. The speed advantage comes from keeping bcmath's C-level string arithmetic as the hot path for decimal operations, while brick/math pays for an extra object-wrapping layer on top of GMP. Integer-only operations (`mod`, `pow`, `powMod`, base conversion) use GMP directly when the extension is available, combining the best of both backends. Realistic workflows like chained calculations or 100-iteration accumulations show a consistent 3-5x advantage, with immutability costing only a lightweight `clone` per operation (two properties: a string and an int).
405
405
406
406
`MathMutable` eliminates the clone overhead entirely for hot loops:
407
407
408
408
| Operation | MathMutable | Math (immutable) | brick/math |
Copy file name to clipboardExpand all lines: pint.json
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
{
2
2
"preset": "laravel",
3
+
"cache-file": ".pint.cache",
3
4
"rules": {
4
5
"header_comment": {
5
6
"header": "This file is part of fab2s/Math.\n(c) Fabrice de Stefanis / https://github.com/fab2s/Math\nThis source file is licensed under the MIT license which you will\nfind in the LICENSE file or at https://opensource.org/licenses/MIT"
0 commit comments