• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

brick / math / 21759044472

06 Feb 2026 04:52PM UTC coverage: 98.516% (-0.7%) from 99.177%
21759044472

push

github

BenMorel
Improve NoInverseException message

1 of 1 new or added line in 1 file covered. (100.0%)

109 existing lines in 4 files now uncovered.

1328 of 1348 relevant lines covered (98.52%)

2303.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Internal/Calculator/BcMathCalculator.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\Math\Internal\Calculator;
6

7
use Brick\Math\Internal\Calculator;
8
use Override;
9

10
use function bcadd;
11
use function bcdiv;
12
use function bcmod;
13
use function bcmul;
14
use function bcpow;
15
use function bcpowmod;
16
use function bcsqrt;
17
use function bcsub;
18

19
/**
20
 * Calculator implementation built around the bcmath library.
21
 *
22
 * @internal
23
 */
24
final readonly class BcMathCalculator extends Calculator
25
{
26
    #[Override]
27
    public function add(string $a, string $b): string
28
    {
UNCOV
29
        return bcadd($a, $b, 0);
3,181✔
30
    }
31

32
    #[Override]
33
    public function sub(string $a, string $b): string
34
    {
UNCOV
35
        return bcsub($a, $b, 0);
3,243✔
36
    }
37

38
    #[Override]
39
    public function mul(string $a, string $b): string
40
    {
UNCOV
41
        return bcmul($a, $b, 0);
6,810✔
42
    }
43

44
    #[Override]
45
    public function divQ(string $a, string $b): string
46
    {
UNCOV
47
        return bcdiv($a, $b, 0);
1,044✔
48
    }
49

50
    #[Override]
51
    public function divR(string $a, string $b): string
52
    {
UNCOV
53
        return bcmod($a, $b, 0);
2,110✔
54
    }
55

56
    #[Override]
57
    public function divQR(string $a, string $b): array
58
    {
UNCOV
59
        $q = bcdiv($a, $b, 0);
3,084✔
UNCOV
60
        $r = bcmod($a, $b, 0);
3,084✔
61

UNCOV
62
        return [$q, $r];
3,084✔
63
    }
64

65
    #[Override]
66
    public function pow(string $a, int $e): string
67
    {
UNCOV
68
        return bcpow($a, (string) $e, 0);
560✔
69
    }
70

71
    #[Override]
72
    public function modPow(string $base, string $exp, string $mod): string
73
    {
74
        // normalize to Euclidean representative so modPow() stays consistent with mod()
UNCOV
75
        $base = $this->mod($base, $mod);
59✔
76

UNCOV
77
        return bcpowmod($base, $exp, $mod, 0);
59✔
78
    }
79

80
    #[Override]
81
    public function sqrt(string $n): string
82
    {
UNCOV
83
        return bcsqrt($n, 0);
5,548✔
84
    }
85
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc