PHPackages                             gries/number-system - 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. gries/number-system

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gries/number-system
===================

A php library to deal with dynamic number systems and conversion

1211PHP

Since Jan 10Pushed 11y ago1 watchersCompare

[ Source](https://github.com/gries/number-system)[ Packagist](https://packagist.org/packages/gries/number-system)[ RSS](/packages/gries-number-system/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (1)

Number-System
=============

[](#number-system)

This PHP-Library can be used to make simple calculations with dynamic number-systems.

[![SensioLabsInsight](https://camo.githubusercontent.com/63a5b1dba08fbc27903c51877b3580ab9b674f5b607e155957013f8fea0cec2c/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35336431343735362d656532392d343333392d393935362d6432663065316232653962372f6269672e706e67)](https://insight.sensiolabs.com/projects/53d14756-ee29-4339-9956-d2f0e1b2e9b7)

[![Build Status](https://camo.githubusercontent.com/aef638f7d4f30642173dcc6d07fb32cd0df1500d602a8c5e49b646a5577ac5a2/68747470733a2f2f7472617669732d63692e6f72672f67726965732f6e756d6265722d73797374656d2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/gries/number-system)

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

[](#installation)

Number-System can be installed via. Composer:

```
composer require "gries/number-system"

```

Usage
-----

[](#usage)

Simple
------

[](#simple)

```
use gries\NumberSystem\HexadecimalSystem;
use gries\NumberSystem\Number;

require_once __DIR__.'/../vendor/autoload.php';

$number = new Number(15); // the default system is decimal
$hexNumber = new Number('FF', new HexadecimalSystem());

echo $number->add($hexNumber)->value(); // 270 (15 + 255)
echo $hexNumber->add($number)->value(); // 10E (F + FF)
```

Custom Number System
--------------------

[](#custom-number-system)

```
use gries\NumberSystem\Number;
use gries\NumberSystem\NumberSystem;

require_once __DIR__.'/../vendor/autoload.php';

$elementalSystem = new NumberSystem(['earth', 'fire', 'air', 'water'], '-');

// diffrent ways of creating a number
$number = new Number('fire-earth', $elementalSystem); // 4
$largerNumber = $elementalSystem->buildNumber(['fire', 'air', 'air']); // 26

// define your own number system and number
class YoloSystem extends NumberSystem
{
    public function __construct()
    {
        parent::__construct(['1337', 'yolo', 'swag'], '¿');
    }
}

class YoloNumber extends Number
{
    public function __construct($value)
    {
        parent::__construct($value, new YoloSystem());
    }
}

$foo = new YoloNumber('yolo¿swag¿yolo¿yolo¿yolo¿yolo¿swag');
echo $foo->asDecimalString(); // 1337
```

Converting Mathematical Expressions
-----------------------------------

[](#converting-mathematical-expressions)

You can use the `ExpressionConverter` to convert mathematical expressions from one system to another.

```
$decimal           = new NumberSystem();
$binary            = new BinaryNumberSystem();
$converter         = new ExpressionConverter();
$decimalExpression = new Expression('(1337 * 7) + sin(5)-2', $decimal);

echo $converter->convert($decimalExpression, $binary); // -> (10100111001 * 111) + sin(101)-10
```

Current limitations aka todo's
------------------------------

[](#current-limitations-aka-todos)

- No support for negative numbers
- No support of floating point numbers
- Division always rounds to 0 because ... no floating point number support ;)

Running the tests
-----------------

[](#running-the-tests)

```
vendor/bin/phpspec run

```

Contribute!
-----------

[](#contribute)

Feel free to give me feedback/feature-request/bug-reports via. github issues. Or just send me a pull-request :)

Author
------

[](#author)

- [Christoph Rosse](http://twitter.com/griesx)

License
-------

[](#license)

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

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

---

Top Contributors

[![gries](https://avatars.githubusercontent.com/u/417823?v=4)](https://github.com/gries "gries (11 commits)")

### Embed Badge

![Health badge](/badges/gries-number-system/health.svg)

```
[![Health](https://phpackages.com/badges/gries-number-system/health.svg)](https://phpackages.com/packages/gries-number-system)
```

###  Alternatives

[cocur/domain

Check domain name availability and WHOIS

691.3k](/packages/cocur-domain)[silverhand7/laravel-artisan-maker

A simple package that can help you to create a boilerplate of a service or action class.

2310.7k](/packages/silverhand7-laravel-artisan-maker)[element119/module-page-builder-custom-data-attributes

A Magento 2 module that allows custom data to be added to Page Builder content.

1316.7k1](/packages/element119-module-page-builder-custom-data-attributes)[lordsimal/bolt-geolocation-field

📝 Bolt Extension to add the Geolocation FieldType

1010.3k](/packages/lordsimal-bolt-geolocation-field)

PHPackages © 2026

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