PHPackages                             scruoge/lib-fractions - 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. scruoge/lib-fractions

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

scruoge/lib-fractions
=====================

Library for precision math calculations based on natural fractions (operates on rational domain)

1.0.0(5mo ago)30MITPHPPHP &gt;=8.2

Since Dec 3Pushed 5mo agoCompare

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

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

lib-fractions
=============

[](#lib-fractions)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/854124dd57cfd3aad3184fca9760bf1f33a5ec1e5d080cfbe8aa4e3337ba46e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e302d3838393242462e737667)](https://php.net/)

A PHP library for precision mathematical calculations using rational numbers. This library operates on the rational domain, providing exact decimal representation without the precision loss inherent in floating-point arithmetic.

Features
--------

[](#features)

- **Exact Precision**: No floating-point rounding errors
- **Rational Number Arithmetic**: Operations on fractions with significand, denominator, and exponent
- **Multiple Input Formats**: Create rational numbers from integers, floats, or explicit fraction components
- **JSON Serializable**: Easy integration with APIs and data storage
- **Comprehensive Operations**: Addition, subtraction, multiplication, division, and comparison
- **Flexible Rounding**: Configurable rounding modes when converting from floats

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

[](#installation)

Install via Composer:

```
composer require scruoge/lib-fractions
```

### Requirements

[](#requirements)

- PHP 8.0 or higher

Quick Start
-----------

[](#quick-start)

```
