Skip to content

idapgroup/Rational-Number

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Relational Namber

PHP Class for Rational numbers manipulations

Installation

The preferred way to install this extension is through composer.

Either run

composer require idapgroup/rational-number

or add

{
  "require": {
    "idapgroup/rational-number": "^1.0.0"
  }
}

to the requirement section of your composer.json file.

Quickstart

$number = new Rational(100);

Create number

$number = new Rational(100);

Operations with numbers

$firstNumber = new Rational(100);
$secondNumber = new Rational(200);

//Multiplication 
$mulResult = $firstNumber->mul($secondNumber);

//Division
$divResult = $firstNumber->div($secondNumber);

//Summarizing
$sumResult = $firstNumber->add($secondNumber);

//Subtraction
$subResult = $firstNumber->sub($secondNumber);

//Сomparison
$equalsResult = $firstNumber->equals($secondNumber);