PHP code example of php-collective / decimal-object

1. Go to this page and download the library: Download php-collective/decimal-object 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/ */

    

php-collective / decimal-object example snippets


var_dump(0.1 + 0.2 === 0.3); // bool(false)

use PhpCollective\DecimalObject\Decimal;

$total = Decimal::create('0.1')->add('0.2');

echo $total;                  // 0.3
var_dump($total->equals('0.3')); // bool(true)