PHP Class for Rational numbers manipulations
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.
$number = new Rational(100);
$number = new Rational(100);
$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);