PHP code example of iamvar / math

1. Go to this page and download the library: Download iamvar/math library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iamvar / math example snippets




$result = bcdiv(bcsub(bcadd($a, bcmul($b, $c)), $d), $e);



$result = calc("$a + $b * $c - $d");



$a = 0.1E1;
$b = 2e-7;
$c = 2;
calc("$a + $b * $c"); // 1.0000004
calc("1.69 ^ (1/2) + (0.1 - 0.25) * 2"); // 1
calc('min(09.12, abs(-10.01))'); // 9.12
calc('max(1, 1.000000000000001)'); // 1.000000000000001

isTrue('(1 + 0.2) * 3 == 3.6 + (1-9) * 0"); // true
isTrue('1 < 2 < 3'); // true
isTrue('1 < 2 > 3'); // false





bcscale(25);
bash
php > var_dump(1.2 * 3);
float(3.5999999999999996)
bash
php > var_dump(calc("1.2 * 3"));
string("3.6")

php > isTrue('1 < 2 < 3'); // true