NumberBase
class NumberBase (View source)
Represents a positional numeral system with a specific number base.
NumberBase provides convenience when dealing numbers that are represented by a specific list of digits. NumberBase can interpret numbers presented as strings and also provides convenience when creating lists of digits.
Methods
Tells if numbers using this numeral system cannot be represented using a string.
Tells if this numeral system is case sensitive or not.
Returns the radix (i.e. base) of the numeral system.
Returns list of all digits in the numeral system.
Tells if the given digit is part of this numeral system.
Returns the decimal value represented by the given digit.
Returns the decimal values for given digits.
Returns the digit representing the given decimal value.
Returns the digits representing the given decimal values.
Finds the largest integer root shared by the radix of both numeral systems.
Replaces all values in the array with actual digits from the digit list.
Splits number string into individual digits.
Details
at line 40
__construct(DigitList|int|string|array $digitList)
Creates a new instance of NumberBase.
The constructor takes a list of digits for the numeral system as the constructor parameter. This can either be an instance of DigitList or it can be a string, an integer or an array that is used to construct the appropriate type of DigitList. See the constructors for appropriate classes for how to define those digit lists.
at line 68
bool
hasStringConflict()
Tells if numbers using this numeral system cannot be represented using a string.
at line 77
bool
isCaseSensitive()
Tells if this numeral system is case sensitive or not.
at line 86
int
getRadix()
Returns the radix (i.e. base) of the numeral system.
at line 95
array
getDigitList()
Returns list of all digits in the numeral system.
at line 105
bool
hasDigit(mixed $digit)
Tells if the given digit is part of this numeral system.
at line 122
int
getValue(mixed $digit)
Returns the decimal value represented by the given digit.
at line 133
int[]
getValues(array $digits)
Returns the decimal values for given digits.
at line 150
mixed
getDigit(int $decimal)
Returns the digit representing the given decimal value.
at line 161
array
getDigits(array $decimals)
Returns the digits representing the given decimal values.
at line 177
int|false
findCommonRadixRoot(NumberBase $base)
Finds the largest integer root shared by the radix of both numeral systems.
at line 213
array
canonizeDigits(array $digits)
Replaces all values in the array with actual digits from the digit list.
This method takes a list of digits and returns the digits properly capitalized and typed. This can be used to canonize numbers when dealing with case insensitive and loosely typed number bases.
at line 226
array
splitString(string $string)
Splits number string into individual digits.