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

brick / math / 17335584781

29 Aug 2025 10:33PM UTC coverage: 99.743%. Remained the same
17335584781

push

github

BenMorel
Apply ECS

209 of 264 new or added lines in 10 files covered. (79.17%)

139 existing lines in 4 files now uncovered.

1165 of 1168 relevant lines covered (99.74%)

1135.14 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
    {
NEW
29
        return bcadd($a, $b, 0);
1,640✔
30
    }
31

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

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

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

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

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

UNCOV
62
        return [$q, $r];
2,054✔
63
    }
64

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

71
    #[Override]
72
    public function modPow(string $base, string $exp, string $mod): string
73
    {
NEW
74
        return bcpowmod($base, $exp, $mod, 0);
12✔
75
    }
76

77
    #[Override]
78
    public function sqrt(string $n): string
79
    {
NEW
80
        return bcsqrt($n, 0);
486✔
81
    }
82
}
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