PHPackages                             moontoast/math - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. moontoast/math

Abandoned → [brick/math](/?search=brick%2Fmath)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

moontoast/math
==============

A mathematics library, providing functionality for large numbers

1.2.1(6y ago)45626.3M↓16.5%7[1 issues](https://github.com/ramsey/moontoast-math/issues)20Apache-2.0PHPPHP &gt;=5.3.3

Since Jan 11Pushed 6y agoCompare

[ Source](https://github.com/ramsey/moontoast-math)[ Packagist](https://packagist.org/packages/moontoast/math)[ Docs](https://github.com/ramsey/moontoast-math)[ RSS](/packages/moontoast-math/feed)WikiDiscussions master Synced yesterday

READMEChangelog (7)Dependencies (5)Versions (8)Used By (20)

***PLEASE NOTE:** This package is abandoned. Please transition to [brick/math](https://github.com/brick/math).*

Moontoast Math Library
======================

[](#moontoast-math-library)

[![Source Code](https://camo.githubusercontent.com/b994417d3025bf79ee49a7ed54d59992524980902f61abbff552ddb8d0669691/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d6d6f6f6e746f6173742f6d6174682d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/ramsey/moontoast-math)[![Latest Version](https://camo.githubusercontent.com/ddc17cc2030cf768136d37b482b46c7019e5610d004f592a7b1cfb09efb65f36/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f6f6e746f6173742f6d6174682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/moontoast/math)[![Software License](https://camo.githubusercontent.com/6b9d0e50a6904b287f69e9f803df20cafb2891f49acaa5b67a137a500e518cf5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f72616d7365792f6d6f6f6e746f6173742d6d6174682e7376673f7374796c653d666c61742d737175617265)](https://github.com/ramsey/moontoast-math/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/d8abdf5f2c22696a06516841ac9ea95684aa7d558237e1f87d392746069c62d2/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f72616d7365792f6d6f6f6e746f6173742d6d6174682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ramsey/moontoast-math)[![Coverage Status](https://camo.githubusercontent.com/cd2a53a77f1e1d244176d5bcbfd5904c710d786743caf89e4afbc70e3b6daf20/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f72616d7365792f6d6f6f6e746f6173742d6d6174682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/ramsey/moontoast-math?branch=master)[![Total Downloads](https://camo.githubusercontent.com/a1f06aebcf9f2b89c303c8a8a4c9022800d17395be3b986ea35366c0d11c2a63/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f6f6e746f6173742f6d6174682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/moontoast/math)

Moontoast\\Math is useful for working with integers that are larger than (or may become larger than, through mathematical computations) PHP's max integer value for a given system. On 64-bit systems, this number is 9223372036854775807. On 32-bit systems, it is 2147483647. When overflowing this boundary, PHP turns the number into a float, reducing precision (see the PHP manual entry for [Integers](http://php.net/manual/en/language.types.integer.php)).

Moontoast\\Math provides an easy-to-use wrapper around the bcmath extension, allowing one to perform mathematical calculations on numeric strings, going well outside the integer range of the system and maintaining arbitrary precision for more precise calculations.

Installation
------------

[](#installation)

The preferred method of installation is via [Composer](https://getcomposer.org/):

```
composer require moontoast/math

```

Examples
--------

[](#examples)

```
$bn = new \Moontoast\Math\BigNumber('9,223,372,036,854,775,808');
$bn->multiply(35);

var_dump($bn->getValue());
var_dump($bn->convertToBase(16));
```

This produces the following output:

```
string(21) "322818021289917153280"
string(18) "118000000000000000"

```

You might want to use BigNumber to work with a UUID, which is an unsigned 128-bit integer. For example:

```
$uuid = \Moontoast\Math\BigNumber::convertToBase10('ff6f8cb0c57d11e19b210800200c9a66', 16);
```

This utility converts the UUID from hexadecimal (base 16) representation to a string representation of the unsigned 128-bit integer in decimal (base 10). You may now create a BigNumber object with it to perform calculations, if you wish.

```
$bn = new \Moontoast\Math\BigNumber($uuid);
echo $bn; // 339532337419071774305803111643925486182
```

License
-------

[](#license)

Copyright © 2013-2020 Moontoast, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity65

Solid adoption and visibility

Community32

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 58.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~425 days

Recently: every ~635 days

Total

7

Last Release

2371d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f514481fa9cfdfd5dbcaccb3e5b480f18ea05ebf331cddf9b1c5a2a96a78fef5?d=identicon)[ramsey](/maintainers/ramsey)

---

Top Contributors

[![ramsey](https://avatars.githubusercontent.com/u/42941?v=4)](https://github.com/ramsey "ramsey (48 commits)")[![terrafrost](https://avatars.githubusercontent.com/u/214474?v=4)](https://github.com/terrafrost "terrafrost (13 commits)")[![proxyd](https://avatars.githubusercontent.com/u/2384867?v=4)](https://github.com/proxyd "proxyd (5 commits)")[![limenet](https://avatars.githubusercontent.com/u/474329?v=4)](https://github.com/limenet "limenet (5 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (4 commits)")[![stefanotorresi](https://avatars.githubusercontent.com/u/2952427?v=4)](https://github.com/stefanotorresi "stefanotorresi (4 commits)")[![h4cc](https://avatars.githubusercontent.com/u/2981491?v=4)](https://github.com/h4cc "h4cc (2 commits)")[![shrikeh](https://avatars.githubusercontent.com/u/445227?v=4)](https://github.com/shrikeh "shrikeh (1 commits)")

---

Tags

bigintegerbignumbermathphpmathbcmath

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/moontoast-math/health.svg)

```
[![Health](https://phpackages.com/badges/moontoast-math/health.svg)](https://phpackages.com/packages/moontoast-math)
```

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.2k548.2M430](/packages/brick-math)[phpseclib/bcmath_compat

PHP 5.x-8.x polyfill for bcmath extension

16821.5M27](/packages/phpseclib-bcmath-compat)[krowinski/bcmath-extended

Extends php BCMath lib for missing functions like floor, ceil, round, abs, min, max, rand for big numbers. Also wraps existing BCMath functions. (more http://php.net/manual/en/book.bc.php) Supports scientific notations

801.1M24](/packages/krowinski-bcmath-extended)[prestashop/decimal

Object-oriented wrapper/shim for BC Math PHP extension. Allows for arbitrary-precision math operations.

178.9M9](/packages/prestashop-decimal)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
