1. Go to this page and download the library: Download tetthys/bc 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/ */
tetthys / bc example snippets
it('shows that 0.1 + 0.2 = 0.3', function () {
expect(0.1 + 0.2)->toBe(0.3);
});
(new Bc)->scale(2)->num('1')->add('2')->mul('3')->value(); // '9.00'
(new Bc('1'))->add(new Bc('2'))->mul(new Bc('3'))->value(); // '9'
(new Bc)->scale(2)->num((new Bc('1')))->add(new Bc('2'))->mul(new Bc('3'))->value(); // '9.00'
// true for '10.00' > '1.00'
(new Bc)->scale(2)->num('10')
->isGreaterThan('1');
// true for '30.00' > '3.00'
(new Bc)->scale(2)->num('10')->add('20')
->isGreaterThan((new Bc)->scale(2)->num('1')->add('2'));
(new Bc)->num('1')
(new Bc('1'))
(new Bc)->num('1')->add('2')->value(); // '3'
// With scale 0, '1' + '2' = '3'
// With scale 2, '3.00' * '3.00' = '9.00'
(new Bc)->num('1')->add('2')->scale(2)->mul('3')->value(); // '9.00'
(new Bc)->num('1')->add('2')->value(); // '3'
(new Bc)->num('2')->sub('1')->value(); // '1'
(new Bc)->num('2')->mul('3')->value(); // '6'
(new Bc)->num('6')->div('3')->value(); // '2'
(new Bc)->num('10')->mod('7')->value(); // '3'
(new Bc)->num('2')->pow('3')->value(); // '8'
(new Bc)->num('2')->powmod('5', '3')->value(); // '2'
(new Bc)->num('9')->sqrt()->value(); // '3'
(new Bc)->num('10')->isGreaterThan('1'); // true
(new Bc)->num('10')->isGreaterThanOrEqual('10'); // true
(new Bc)->num('1')->isLessThan('10'); // true
(new Bc)->num('10')->isLessThanOrEqual('10'); // true
(new Bc)->num('10')->isEqual('10'); // true
(new Bc)->num('10')->isDifferent('1'); // true
(new Bc)->num('10')->gt('1'); // true
(new Bc)->num('10')->gte('10'); // true
(new Bc)->num('1')->lt('10'); // true
(new Bc)->num('10')->lte('10'); // true
(new Bc)->num('10')->is('10'); // true
(new Bc)->num('10')->isNot('1'); // true
throw new \Tetthys\Bc\Exceptions\ScaleCannotBeUsedForOperation;
throw new \Tetthys\Bc\Exceptions\ValueCannotBeUsedForOperation;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.