You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 27, 2023. It is now read-only.
Andreu Correa Casablanca edited this page Mar 18, 2015
·
1 revision
Requirements
Litipk PHP BigNumbers supports PHP 5.3.x, 5.4.x, 5.5.x, and 5.6.,x
but also Facebook's HHVM. In any case, we recommend to use the latest PHP versions or HHVM.
<?phpuse \Litipk\BigNumbers\DecimalasDecimal;
/** * There are many ways to create Decimal objects. */$ten = Decimal::fromInteger(10);
$two = Decimal::fromString('2.0');
/** * At this moment there are few binary operators * that we can use with Decimal objects: */$twenty = $ten->mul($two);
$fifty = $twenty->add(Decimal::fromFloat(30.));
/** * There are many unary operators too: */$five = Decimal::fromInteger(-5)->abs();
$five->additiveInverse()->equals(Decimal::fromInteger(-5)); // returns true/** * You can check many properties of your numbers: */$zero = Decimal::fromInteger(0);
$zero->isZero(); // Returns true?>
Importing the Litipk\BigNumbers classes
Because Litipk\BigNumbers is distributed through Composer and follows the PSR-4 standard, it uses classes autoloading. If you don't know how to use it, you should read this section of Composer's documentation.
The public classes in the library are:
Decimal : With this class you can create numbers with arbitrary precision.
InfiniteDecimal : With this class you can deal with infinite values.
NumConstants : If you need using important numerical constants, this class will help you.
To import a specific class, you must add the following line in the header of your PHP script (Change ClassName with one of the listed public classes):