Documentation

BrickMathCalculator
in package
implements CalculatorInterface

A calculator using the brick/math library for arbitrary-precision arithmetic

Tags
psalm-immutable

Interfaces, Classes, Traits and Enums

CalculatorInterface
A calculator performs arithmetic operations on numbers

Table of Contents

ROUNDING_MODE_MAP  = [\Ramsey\Uuid\Math\RoundingMode::UNNECESSARY => \Brick\Math\RoundingMode::UNNECESSARY, \Ramsey\Uuid\Math\RoundingMode::UP => \Brick\Math\RoundingMode::UP, \Ramsey\Uuid\Math\RoundingMode::DOWN => \Brick\Math\RoundingMode::DOWN, \Ramsey\Uuid\Math\RoundingMode::CEILING => \Brick\Math\RoundingMode::CEILING, \Ramsey\Uuid\Math\RoundingMode::FLOOR => \Brick\Math\RoundingMode::FLOOR, \Ramsey\Uuid\Math\RoundingMode::HALF_UP => \Brick\Math\RoundingMode::HALF_UP, \Ramsey\Uuid\Math\RoundingMode::HALF_DOWN => \Brick\Math\RoundingMode::HALF_DOWN, \Ramsey\Uuid\Math\RoundingMode::HALF_CEILING => \Brick\Math\RoundingMode::HALF_CEILING, \Ramsey\Uuid\Math\RoundingMode::HALF_FLOOR => \Brick\Math\RoundingMode::HALF_FLOOR, \Ramsey\Uuid\Math\RoundingMode::HALF_EVEN => \Brick\Math\RoundingMode::HALF_EVEN]
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
getBrickRoundingMode()  : int
Maps ramsey/uuid rounding modes to those used by brick/math

Constants

ROUNDING_MODE_MAP

private mixed ROUNDING_MODE_MAP = [\Ramsey\Uuid\Math\RoundingMode::UNNECESSARY => \Brick\Math\RoundingMode::UNNECESSARY, \Ramsey\Uuid\Math\RoundingMode::UP => \Brick\Math\RoundingMode::UP, \Ramsey\Uuid\Math\RoundingMode::DOWN => \Brick\Math\RoundingMode::DOWN, \Ramsey\Uuid\Math\RoundingMode::CEILING => \Brick\Math\RoundingMode::CEILING, \Ramsey\Uuid\Math\RoundingMode::FLOOR => \Brick\Math\RoundingMode::FLOOR, \Ramsey\Uuid\Math\RoundingMode::HALF_UP => \Brick\Math\RoundingMode::HALF_UP, \Ramsey\Uuid\Math\RoundingMode::HALF_DOWN => \Brick\Math\RoundingMode::HALF_DOWN, \Ramsey\Uuid\Math\RoundingMode::HALF_CEILING => \Brick\Math\RoundingMode::HALF_CEILING, \Ramsey\Uuid\Math\RoundingMode::HALF_FLOOR => \Brick\Math\RoundingMode::HALF_FLOOR, \Ramsey\Uuid\Math\RoundingMode::HALF_EVEN => \Brick\Math\RoundingMode::HALF_EVEN]

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

getBrickRoundingMode()

Maps ramsey/uuid rounding modes to those used by brick/math

private getBrickRoundingMode(int $roundingMode) : int
Parameters
$roundingMode : int
Return values
int

Search results