mocking-magician / mathoraptor
Dealing with big numbers in PHP
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/mocking-magician/mathoraptor
Requires
- php: ^7.1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15
- phpbench/phpbench: @dev
- phpstan/phpstan: @dev
- phpunit/phpunit: ^8
This package is auto-updated.
Last update: 2025-09-25 06:34:47 UTC
README
mathoraptor is a PHP library for dealing with big number in an object mode.
Install
Simply run
composer require mocking-magician/mathoraptor
Examples
<? use MockingMagician\Mathoraptor\Number\BigNumber; use MockingMagician\Mathoraptor\Number\BigInteger; use MockingMagician\Mathoraptor\Number\BigFraction; use MockingMagician\Mathoraptor\Exceptions\ParseIntegerException; // float $bigNumber = BigNumber::fromString('1.2'); // or integer $bigNumber = BigNumber::fromString('1'); // or strict integer $bigInteger = BigInteger::fromString('1'); try { // that throw an error if not integer $bigInteger = BigInteger::fromString('1.1'); } catch (ParseIntegerException $e) { } // fraction $bigFraction = new BigFraction(BigInteger::fromString('11'), BigInteger::fromString('7')); // for each number type, available operations are : // - add // - sub // - multiplyBy // - divideBy $bigNumber->add($bigInteger); // return a new BigNumber $bigNumber->sub($bigInteger); // return a new BigNumber // ... multiplyBy // ... divideBy $bigNumber->add($bigFraction); // return a new BigFraction // ... multiplyBy // ... divideBy
What's next ?
- Adding more operation like pow, mod, etc...