2017 © Pedro Peláez
 

library positive-modulus

Modulus returning always positive numbers

image

antonienko/positive-modulus

Modulus returning always positive numbers

  • Monday, June 15, 2015
  • by antonienko
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,135 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Positive Modulus

Build Status, (*1)

Php modulus operator %, when working with negative numbers will return negative results., (*2)

People with a mathematical background sometimes would expect that modulus is always positive., (*3)

That's the case when you are trying to iterate on a set of elements by decrementing the iterator, when you reach -1, you want the modulus operation to give you the highest number again to continue the iteration on the last element., (*4)

After some research, I found that both behaviours could be mathematically correct, so this library is for those who need a modulus that always returns a positive result., (*5)

Installation

Composer

This library is available in packagist.org, you can add it to your project via Composer., (*6)

In the "require" section of your composer.json file:, (*7)

Always up to date (bleeding edge, API not guaranteed stable), (*8)

"antonienko/positive-modulus": "dev-master"

Specific minor version, API stability, (*9)

"antonienko/positive-modulus": "0.2.*"

If you have any problems with the minimum-stability setting try appending @dev to the version, (*10)

"antonienko/positive-modulus": "0.2.*@dev"

Sample Usage

PositiveModulus::calc($a, $b);

License Information

Lincensed under The MIT License (MIT). See the LICENSE file for more details., (*11)

The Versions

15/06 2015

dev-master

9999999-dev

Modulus returning always positive numbers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

math modulus

15/06 2015

v1.0

1.0.0.0

Modulus returning always positive numbers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

math modulus