<commit_before>Rounder [![Build Status](https://travis-ci.org/pamil/Rounder.png?branch=master)](https://travis-ci.org/pamil/Rounder) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/363d3fa3-5a35-427b-8844-d466370e7ce5/mini.png)](https://insight.sensiolabs.com/projects/363d3fa3-5a35-427b-8844-d466370e7ce5)
=======

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.

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

 * Run `composer required pamil/rounder:dev-master`
 * Play with it!

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

$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<commit_msg>Spelling correct / information about supported environments<commit_after>Rounder [![Build Status](https://travis-ci.org/pamil/Rounder.png?branch=master)](https://travis-ci.org/pamil/Rounder) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/363d3fa3-5a35-427b-8844-d466370e7ce5/mini.png)](https://insight.sensiolabs.com/projects/363d3fa3-5a35-427b-8844-d466370e7ce5)
=======

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 >= 5.3** and **HHVM**.

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

 * Run `composer require pamil/rounder:dev-master`
 * Play with it!

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

$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
{'fraction_non_alphanumeric': 0.16203104786545924, 'fraction_numerical': 0.04915912031047866, 'mean_word_length': 4.846880907372401, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6825777', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1015, 'n_words': 279}