PHP code example of timg / decimal
1. Go to this page and download the library: Download timg/decimal 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/ */
timg / decimal example snippets
$calculation = lazy_calc(dec(0))
->add(lazy_calc(rat(1, 3))->round(2))
->add(lazy_calc(rat(1, 3))->round(2))
->add(lazy_calc(rat(1, 3))->round(3));
static::assertSame(
'(((0 + round((1 / 3), scale = 2)) + round((1 / 3), scale = 2)) + round((1 / 3), scale = 3))',
$calculation->pretty()
);