Calculators¶

interface
Ramsey\Uuid\Math\
CalculatorInterface
¶ Provides functionality for performing mathematical calculations.

add
($augend, ...$addends)¶  Parameters
$augend (Ramsey\Uuid\Type\NumberInterface) – The first addend (the integer being added to)
...$addends (Ramsey\Uuid\Type\NumberInterface) – The additional integers to a add to the augend
 Returns
The sum of all the parameters
 Return type

subtract
($minuend, ...$subtrahends)¶  Parameters
$minuend (Ramsey\Uuid\Type\NumberInterface) – The integer being subtracted from
...$subtrahends (Ramsey\Uuid\Type\NumberInterface) – The integers to subtract from the minuend
 Returns
The difference after subtracting all parameters
 Return type

multiply
($multiplicand, ...$multipliers)¶  Parameters
$multiplicand (Ramsey\Uuid\Type\NumberInterface) – The integer to be multiplied
...$multipliers (Ramsey\Uuid\Type\NumberInterface) – The factors by which to multiply the multiplicand
 Returns
The product of multiplying all the provided parameters
 Return type

divide
($roundingMode, $scale, $dividend, ...$divisors)¶  Parameters
$roundingMode (int) – The strategy for rounding the quotient; one of the
Ramsey\Uuid\Math\RoundingMode
constants$scale (int) – The scale to use for the operation
$dividend (Ramsey\Uuid\Type\NumberInterface) – The integer to be divided
...$divisors (Ramsey\Uuid\Type\NumberInterface) – The integers to divide
$dividend
by, in the order in which the division operations should take place (lefttoright)
 Returns
The quotient of dividing the provided parameters lefttoright
 Return type

fromBase
($value, $base)¶ Converts a value from an arbitrary base to a base10 integer value.
 Parameters
$value (string) – The value to convert
$base (int) – The base to convert from (i.e., 2, 16, 32, etc.)
 Returns
The base10 integer value of the converted value
 Return type

toBase
($value, $base)¶ Converts a base10 integer value to an arbitrary base.
 Parameters
$value (Ramsey\Uuid\Type\Integer) – The integer value to convert
$base (int) – The base to convert to (i.e., 2, 16, 32, etc.)
 Returns
The value represented in the specified base
 Return type
string

toHexadecimal
($value)¶ Converts an Integer instance to a Hexadecimal instance.
 Parameters
$value (Ramsey\Uuid\Type\Integer) – The Integer to convert to Hexadecimal
 Return type

toInteger
($value)¶ Converts a Hexadecimal instance to an Integer instance.
 Parameters
$value (Ramsey\Uuid\Type\Hexadecimal) – The Hexadecimal to convert to Integer
 Return type


class
Ramsey\Uuid\Math\
RoundingMode
¶ 
constant
UNNECESSARY
¶ Asserts that the requested operation has an exact result, hence no rounding is necessary.

constant
UP
¶ Rounds away from zero.
Always increments the digit prior to a nonzero discarded fraction. Note that this rounding mode never decreases the magnitude of the calculated value.

constant
DOWN
¶ Rounds towards zero.
Never increments the digit prior to a discarded fraction (i.e., truncates). Note that this rounding mode never increases the magnitude of the calculated value.

constant
CEILING
¶ Rounds towards positive infinity.
If the result is positive, behaves as for
UP
; if negative, behaves as forDOWN
. Note that this rounding mode never decreases the calculated value.

constant
FLOOR
¶ Rounds towards negative infinity.
If the result is positive, behave as for
DOWN
; if negative, behave as forUP
. Note that this rounding mode never increases the calculated value.

constant
HALF_UP
¶ Rounds towards “nearest neighbor” unless both neighbors are equidistant, in which case round up.
Behaves as for
UP
if the discarded fraction is >= 0.5; otherwise, behaves as forDOWN
. Note that this is the rounding mode commonly taught at school.

constant
HALF_DOWN
¶ Rounds towards “nearest neighbor” unless both neighbors are equidistant, in which case round down.
Behaves as for
UP
if the discarded fraction is > 0.5; otherwise, behaves as forDOWN
.

constant
HALF_CEILING
¶ Rounds towards “nearest neighbor” unless both neighbors are equidistant, in which case round towards positive infinity.
If the result is positive, behaves as for
HALF_UP
; if negative, behaves as forHALF_DOWN
.

constant
HALF_FLOOR
¶ Rounds towards “nearest neighbor” unless both neighbors are equidistant, in which case round towards negative infinity.
If the result is positive, behaves as for
HALF_DOWN
; if negative, behaves as forHALF_UP
.

constant
HALF_EVEN
¶ Rounds towards the “nearest neighbor” unless both neighbors are equidistant, in which case rounds towards the even neighbor.
Behaves as for
HALF_UP
if the digit to the left of the discarded fraction is odd; behaves as forHALF_DOWN
if it’s even.Note that this is the rounding mode that statistically minimizes cumulative error when applied repeatedly over a sequence of calculations. It is sometimes known as “Banker’s rounding”, and is chiefly used in the USA.

constant