PHPackages                             spacegrass/fraction - 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. spacegrass/fraction

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

spacegrass/fraction
===================

A composer-installable fractions library

1.0(7y ago)089MITPHPPHP &gt;=7.2.0

Since Jun 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dallincoons/fraction)[ Packagist](https://packagist.org/packages/spacegrass/fraction)[ RSS](/packages/spacegrass-fraction/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Spacegrass Fraction
===================

[](#spacegrass-fraction)

Composer-installable fractions for PHP

Usage
-----

[](#usage)

```
use Spacegrass\Fraction;
```

#### Simple Fractions

[](#simple-fractions)

```
echo new Fraction(1, 2); // 1/2
echo new Fraction(5, 2); // 2 1/2
```

#### Create Fraction from string

[](#create-fraction-from-string)

```
echo Fraction::fromString('1 2/3'); // 1 2/3
echo Fraction::fromString('28/4'); // 7
```

#### Create Fraction from float

[](#create-fraction-from-float)

```
echo Fraction::fromFloat(1.5); // 1 1/2
```

#### Auto-simplified

[](#auto-simplified)

Fractions are simplified at construction

```
echo new Fraction(4, 6); // 2/3
```

#### Addition

[](#addition)

```
$fraction = new Fraction(2, 7);
echo $fraction->add(new Fraction(3, 11)); // 43/77
```

#### Subtraction

[](#subtraction)

```
$fraction = new Fraction(6);
echo $fraction->subtract(new Fraction(2, 3)); // 5 1/3
```

#### Multiplication

[](#multiplication)

```
$fraction = new Fraction(1, 2);
echo $fraction->multiply(new Fraction(1, 2)); // 1/4
```

#### Division

[](#division)

```
$fraction = new Fraction(6, 13);
echo $fraction->divide(new Fraction(2, 7)); // 1 8/13
```

#### To Float

[](#to-float)

```
$fraction = new Fraction(1, 8);
$fraction->toFloat(); // 0.125
```

#### Is Integer?

[](#is-integer)

Check whether a fraction is in fact a whole number.

```
$fraction = new Fraction(1, 8);
$fraction->isInteger(); // false

$fraction = new Fraction(16, 8);
$fraction->isInteger(); // true
```

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

[](#installation)

run `composer require spacegrass/fraction`

or

Add package to your composer.json file

```
{
    "require": {
        "spacegrass/fraction": "dev-master"
    }
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Unknown

Total

1

Last Release

2890d ago

### Community

Maintainers

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

---

Top Contributors

[![dallincoons](https://avatars.githubusercontent.com/u/6494464?v=4)](https://github.com/dallincoons "dallincoons (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spacegrass-fraction/health.svg)

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

###  Alternatives

[wata727/pahout

A pair programming partner for writing better PHP

4814.7k1](/packages/wata727-pahout)[simonstamm/laravel-pjax

PJAX for Laravel 4 with redirection-support

238.3k](/packages/simonstamm-laravel-pjax)

PHPackages © 2026

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