Documentation

CalculatorInterface

A calculator performs arithmetic operations on numbers

Tags
psalm-immutable

Table of Contents

add()  : NumberInterface
Returns the sum of all the provided parameters
divide()  : NumberInterface
Returns the quotient of the provided parameters divided left-to-right
fromBase()  : Integer
Converts a value from an arbitrary base to a base-10 integer value
multiply()  : NumberInterface
Returns the product of all the provided parameters
subtract()  : NumberInterface
Returns the difference of all the provided parameters
toBase()  : string
Converts a base-10 integer value to an arbitrary base
toHexadecimal()  : Hexadecimal
Converts an Integer instance to a Hexadecimal instance
toInteger()  : Integer
Converts a Hexadecimal instance to an Integer instance

Methods

divide()

Returns the quotient of the provided parameters divided left-to-right

public divide(int $roundingMode, int $scale, NumberInterface $dividend, NumberInterface ...$divisors) : NumberInterface
Parameters
$roundingMode : int

The RoundingMode constant to use for this operation

$scale : int

The scale to use for this operation

$dividend : NumberInterface

The integer to be divided

$divisors : NumberInterface

The integers to divide $dividend by, in the order in which the division operations should take place (left-to-right)

Return values
NumberInterface

The quotient of dividing the provided parameters left-to-right

fromBase()

Converts a value from an arbitrary base to a base-10 integer value

public fromBase(string $value, int $base) : Integer
Parameters
$value : string

The value to convert

$base : int

The base to convert from (i.e., 2, 16, 32, etc.)

Return values
Integer

The base-10 integer value of the converted value

toBase()

Converts a base-10 integer value to an arbitrary base

public toBase(Integer $value, int $base) : string
Parameters
$value : Integer

The integer value to convert

$base : int

The base to convert to (i.e., 2, 16, 32, etc.)

Return values
string

The value represented in the specified base

Search results