2017 © Pedro Peláez
 

library rinc

Round numbers to increments

image

jnjxp/rinc

Round numbers to increments

  • Friday, July 22, 2016
  • by jnj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

jnjxp.rinc

Round numbers to increments, (*1)

Latest version ![Build Status][ico-travis] Coverage Status ![Quality Score][ico-code-quality], (*2)

Installation

composer require jnjxp/rinc

Usage

use Jnjxp\Rinc;

// Rounder
$roundTo = new Rinc\RoundTo;

echo $roundTo->nearest(1/4, 0.24);  // 0.25
echo $roundTo->next(1/4, 0.26);     // 0.5
echo $roundTo->previous(1/4, 0.46); // 0.25

// Increment
$quarter = new Rinc\Increment(1/4);
echo $quarter(0.24);           // 0.25 (same as nearest())
echo $quarter->nearest(0.24);  // 0.25
echo $quarter->next(0.26);     // 0.5
echo $quarter->previous(0.46); // 0.25

// Named Convenience Constructors
$eighth  = Rinc\Increment::eighth();  // new Rinc\Increment(1/8)
$quarter = Rinc\Increment::quarter(); // new Rinc\Increment(1/4)
$half    = Rinc\Increment::half();    // new Rinc\Increment(1/2)

The Versions

22/07 2016

dev-develop

dev-develop https://github.com/jnjxp/jnjxp.rinc

Round numbers to increments

  Sources   Download

MIT

by jake johns

22/07 2016

dev-master

9999999-dev https://github.com/jnjxp/jnjxp.rinc

Round numbers to increments

  Sources   Download

MIT

by jake johns

22/07 2016

0.1.0

0.1.0.0 https://github.com/jnjxp/jnjxp.rinc

Round numbers to increments

  Sources   Download

MIT

by jake johns