Documentation

CalculatorInterface

The calculator interface that all abstract & concrete calculator classes should implement.

Tags
version
1.0.0
since
0.4.1
author

Jordan Brauer 18744334+jordanbrauer@users.noreply.github.com

codeCoverageIgnore

Table of Contents

add()  : int|float|string
Add two arbitrary precision numbers
div()  : int|float|string
Divide two arbitrary precision numbers
getPrecision()  : int
Returns the current decimal precision for the calculator
getRoundingMode()  : int
Return the current rounding mode
mod()  : int|float|string
Get modulus of an arbitrary precision number
mul()  : int|float|string
Multiply two arbitrary precision numbers
pow()  : int|float|string
Raise an arbitrary precision number to another
round()  : int|float|string
Rounds a float.
setPrecision()  : Calculator
Set default decimal precision for all math functions
setRoundingMode()  : CalculatorInterface
Use one of the PHP_ROUND_HALF_* constants to specify the mode in which rounding occurs.
sub()  : int|float|string
Subtract one arbitrary precision number from another

Methods

add()

Add two arbitrary precision numbers

public add(int|float|string $leftOperand, int|float|string $rightOperand) : int|float|string
Parameters
$leftOperand : int|float|string

The number left of the operator

$rightOperand : int|float|string

The number right of the operator

Return values
int|float|string

div()

Divide two arbitrary precision numbers

public div(int|float|string $dividend, int|float|string $divisor) : int|float|string
Parameters
$dividend : int|float|string

The number beind divided

$divisor : int|float|string

The number that is doing the dividing

Return values
int|float|string

getPrecision()

Returns the current decimal precision for the calculator

public getPrecision() : int
Return values
int

getRoundingMode()

Return the current rounding mode

public getRoundingMode() : int
Return values
int

mod()

Get modulus of an arbitrary precision number

public mod(int|float|string $dividend, int|float|string $modulus) : int|float|string
Parameters
$dividend : int|float|string

The dividend as a string

$modulus : int|float|string

The modulus as a string

Return values
int|float|string

mul()

Multiply two arbitrary precision numbers

public mul(int|float|string $leftOperand, int|float|string $rightOperand) : int|float|string
Parameters
$leftOperand : int|float|string

The number left of the operator

$rightOperand : int|float|string

The number right of the operator

Return values
int|float|string

pow()

Raise an arbitrary precision number to another

public pow(int|float|string $base, int|float|string $exponent) : int|float|string
Parameters
$base : int|float|string

The base, as a string.

$exponent : int|float|string

The exponent, as a string. If the exponent is non-integral, it is truncated. The valid range of the exponent is platform specific, but is at least -2147483648 to 2147483647.

Return values
int|float|string

round()

Rounds a float.

public round(int|float|string $value[, int $precision = null ]) : int|float|string
Parameters
$value : int|float|string

The value to round

$precision : int = null

The number of decimal digits to round to.

Return values
int|float|string

setPrecision()

Set default decimal precision for all math functions

public setPrecision(int $precision) : Calculator
Parameters
$precision : int

The amount of decimal places that will be returned

Return values
Calculator

sub()

Subtract one arbitrary precision number from another

public sub(int|float|string $leftOperand, int|float|string $rightOperand) : int|float|string
Parameters
$leftOperand : int|float|string

The number left of the operator

$rightOperand : int|float|string

The number right of the operator

Return values
int|float|string

Search results