1<?php
2
3const STRING_PADDING = 30;
4
5function run_bcmath_tests(
6    $firstTerms,
7    $secondTerms,
8    $symbol,
9    $bcmath_function
10) {
11    $scales = [0, 10];
12    foreach ($scales as $scale) {
13        foreach ($firstTerms as $firstTerm) {
14            echo "Number \"$firstTerm\" (scale $scale)\n";
15            foreach ($secondTerms as $secondTerm) {
16                try {
17                    $ret = $bcmath_function($firstTerm, $secondTerm, $scale);
18                } catch (Throwable $e) {
19                    $ret = $e->getMessage();
20                }
21                echo $firstTerm,
22                    " $symbol ",
23                    str_pad($secondTerm, STRING_PADDING),
24                    " = ",
25                    $ret,
26                    "\n";
27            }
28            echo "\n";
29        }
30    }
31}
32