PHPackages                             pamil/rounder - 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. pamil/rounder

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

pamil/rounder
=============

Simple round utility

v2.0(12y ago)142MITPHPPHP &gt;=5.3

Since Dec 31Pushed 12y ago1 watchersCompare

[ Source](https://github.com/pamil/Rounder)[ Packagist](https://packagist.org/packages/pamil/rounder)[ RSS](/packages/pamil-rounder/feed)WikiDiscussions master Synced 2mo ago

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

Rounder [![Build Status](https://camo.githubusercontent.com/efecb1d79669276530412362cf101d60d009dcd5fc4b942d3be2dd7ca9d7bc4f/68747470733a2f2f7472617669732d63692e6f72672f70616d696c2f526f756e6465722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/pamil/Rounder) [![SensioLabsInsight](https://camo.githubusercontent.com/cfd93d4e32e5cb692746cac69968a0763484d32adee8c074234234b8bf76c7e9/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f33363364336661332d356133352d343237622d383834342d6434363633373065376365352f6d696e692e706e67)](https://insight.sensiolabs.com/projects/363d3fa3-5a35-427b-8844-d466370e7ce5)
===================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#rounder--)

Simple round utility for PHP as equivalent for `\round()` function. Provides interface and default, safe, unit-tested implementation for rounding:

- **half up** (half towards positive infinity)
- **half down** (half towards negative infinity)
- **half even**
- **half odd**
- **half away from zero** (half towards infinity)
- **half towards zero** (half away from infinity)
- **up** (towards positive infinity)
- **down** (towards negative infinity)
- **away from zero** (towards infinity)
- **towards zero** (away from infinity)

Unlike `round()`, where `PHP_ROUND_HALF_UP` rounding mode means rounding half away from zero and `PHP_ROUND_HALF_DOWN` means rounding half towards zero, **Rounder** provides correct implementation of these rounding modes.

Supports **PHP &gt;= 5.3** and **HHVM**.

How to use?
-----------

[](#how-to-use)

- Run `composer require "pamil/rounder:~2.0"`
- Play with it!

```
use Pamil\Rounder\Rounder;
use Pamil\Rounder\BasicRounder;

$rounder = new BasicRounder();

// Use new API
$rounder->roundHalfUp(12.15, 1); // 12.2
$rounder->roundHalfUp(-12.315, 2); // -12.31

// Or old round API
$rounder->round(24.5); // 25
$rounder->round(24.5, 0, Rounder::ROUND_DOWN); // 24

// You can even use old PHP_ROUND_* constants
// Warning: as mentioned above, PHP_ROUND_HALF_UP and
// PHP_ROUND_HALF_DOWN have been badly named, so they
// aren't equivalent for Rounder::ROUND_HALF_UP and
// Rounder::ROUND_HALF_DOWN. They are 100% back compatibile,
// $rounder->round() returns the same values round() will return.

$rounder->round(23.5, 0, PHP_ROUND_HALF_EVEN); // 24
$rounder->round(22.5, 0, PHP_ROUND_HALF_EVEN); // 22
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~28 days

Total

2

Last Release

4489d ago

Major Versions

v1.0 → v2.02014-01-28

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pamil-rounder/health.svg)

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

###  Alternatives

[borisguery/inflexible

Collection of Inflectors for string, date, numbers, etc.

201.8k](/packages/borisguery-inflexible)

PHPackages © 2026

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