PHPackages                             felixdorn/sey - 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. felixdorn/sey

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

felixdorn/sey
=============

Sey is a powerful math interpreter with arbitrary-precision.

1.0.0(4y ago)1213MITPHPPHP ^8.0

Since Nov 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/felixdorn/sey)[ Packagist](https://packagist.org/packages/felixdorn/sey)[ RSS](/packages/felixdorn-sey/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

[![The word Sey on a blue background](art/logo.svg)](art/logo.svg)

Sey
===

[](#sey)

[![Tests](https://github.com/felixdorn/sey/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/felixdorn/sey/actions/workflows/tests.yml)[![Formats](https://github.com/felixdorn/sey/actions/workflows/formats.yml/badge.svg?branch=main)](https://github.com/felixdorn/sey/actions/workflows/formats.yml)[![Version](https://camo.githubusercontent.com/4c30d5c9486e81443d1d69687e5fbc9e7cdf64312eaa8a178f11053ea19a546c/68747470733a2f2f706f7365722e707567782e6f72672f66656c6978646f726e2f7365792f76657273696f6e)](//packagist.org/packages/felixdorn/sey)[![Total Downloads](https://camo.githubusercontent.com/7e89c91e0c1e2e7b4fa829acfee95c70cf6f3e2c8b3531920ee18ee37778c7c5/68747470733a2f2f706f7365722e707567782e6f72672f66656c6978646f726e2f7365792f646f776e6c6f616473)](//packagist.org/packages/felixdorn/sey)[![License](https://camo.githubusercontent.com/be8b24a6122556d5067ca6e80c0e369b8c51d3e78b5b10b762302297dec80566/68747470733a2f2f706f7365722e707567782e6f72672f66656c6978646f726e2f7365792f6c6963656e7365)](//packagist.org/packages/felixdorn/sey)

Sey, pronounce say, is a powerful math interpreter with arbitrary-precision.

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

[](#installation)

> Requires [PHP 8.0.0+](https://php.net/releases) and the `bcmath` extension

You can install the package via composer:

```
composer require felixdorn/sey
```

Usage
-----

[](#usage)

```
Sey::parse('(0.5 + 0.5) / 3)'); // 0.3333333333333333
// or
sey('a / b', ['a' => 1, 'b' => 2]); // 0.5
```

### Precision

[](#precision)

By default, the maximum floating precision is 16.

You may change it:

```
\Felix\Sey\Sey:precision(32);
```

Syntax
------

[](#syntax)

It's just math.

```
1 + 2
2 - 3
3 * 4
4 / 5
5 % 6
6 ^ 7
7 * (8 + 9)
sqrt(10)
powmod(11)
11(12 - 13)
(14 + 15)^16
!(5)
pi()

```

### Variables

[](#variables)

You can not define variables in your code but you can pass them at compile-time.

```
Sey::parse('2 * r * pi', [
    'r' => 10,
    'pi' => 3.1415
]);
```

### Functions

[](#functions)

- `sqrt`: `bcsqrt`
- `powmod`: `bcpowmod`
- `pi()`: custom `bcpi` function

    This function returns pi with your defined precision up to 999 digits.
- `!(n)`: custom `bcfact` function

    This computes `n!`, if you need to do it really quickly, you should probably use a lookup table.

#### Custom functions

[](#custom-functions)

> You can override built-ins functions.

```
Sey::define('!', function (int $n, /* as many arguments as you want */) {
    return $factorials[$n] ?? bcfact($n);
});
```

The function name must match the following regex `[a-z_A-Z!]+[a-z_A-Z0-9]*`.

So, first character must be a letter or ! followed by any number of letters or numbers.

### Tests

[](#tests)

```
composer test
```

**sey** was created by **[Félix Dorn](https://twitter.com/afelixdorn)** under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1652d ago

Major Versions

0.1.0 → 1.0.02021-11-05

### Community

Maintainers

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

---

Top Contributors

[![felixdorn](https://avatars.githubusercontent.com/u/55788595?v=4)](https://github.com/felixdorn "felixdorn (28 commits)")

---

Tags

arbitrary-precisionbcmathpackagephp

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/felixdorn-sey/health.svg)

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

###  Alternatives

[streamcommon/promise

PHP-CLI promise implementation

152.0k](/packages/streamcommon-promise)

PHPackages © 2026

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