PHP code example of xethron / bignum

1. Go to this page and download the library: Download xethron/bignum 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/ */

    

xethron / bignum example snippets




use Xethron\Bignum\Math;

Math::add(7, 3); // 10
Math::subtract('1', '0.000001'); // 0.999999

// Default 20 precision
Math::divide(1, 3); // 0.33333333333333333333

// Set precision to 4 decimals
$third = Math::divide(1, 3, 4); // 0.3333
// Set precision to 2, resulting in rounding 0.9999 to 1
$one = Math::multiply($third, 3, 2); // 1

Math::round(0.5678); // 1
Math::round(0.16, 1); // 0.2