Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mockingmagician/mathoraptor
Dealing with big number in PHP
https://github.com/mockingmagician/mathoraptor
Last synced: 5 days ago
JSON representation
Dealing with big number in PHP
- Host: GitHub
- URL: https://github.com/mockingmagician/mathoraptor
- Owner: MockingMagician
- License: other
- Created: 2019-06-21T08:56:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-24T20:21:24.000Z (over 3 years ago)
- Last Synced: 2024-05-01T18:00:04.576Z (7 months ago)
- Language: PHP
- Size: 85 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Description
mathoraptor is a PHP library for dealing with big number in an object mode.
# Install
Simply run
````bash
composer require mocking-magician/mathoraptor
````# Examples
````PHP
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...