PHP code example of cydrickn / number

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

    

cydrickn / number example snippets


use Cydrickn\Number\Number;

Number::setConfig(array('places'=>20,'round'=>true));

$num = new Number(0.1);

plus($num)

$x = new Number(1.2);
$x->plus(3.2);          // 4.4

minus($num)

$x = new Number(4.2);
$x->minus(3.2);          // 1

times($num)

$x = new Number(1.2);
$x->times(2);          // 2.4

dividedBy($num)

$x = new Number(10.68);
$x->dividedBy(2);          // 5.34

modulo($num)

$x = new Number(10);
$x->modulo(3);          // 1

equals($num)

$x = new Number(10);
$x->equals(10);         // true

notEqual($num)

$x = new Number(10);
$x->notEqual(10);       // false

greaterThan($num)

$x = new Number(10);
$x->greaterThan(10);     // false

greaterThanOrEqual($num)

$x = new Number(10);
$x->greaterThanOrEqual(10);      // true

lessThan($num)

$x = new Number(10);
$x->lessThan(11);               // true

lessThanOrEqual($num)

$x = new Number(10);
$x->lessThanOrEqual(9);         // false