Class ReplaceConverter
Converts numbers using character replacement.
ReplaceConverter converts numbers from base to another using a simple string
replacement strategy. In other words. The digits from one base is simply
replaced with digits from the other base. This strategy, however, is only
possible if the two number bases share a common root or if the target number
base is nth root of the source base. This is required, because it allows
a sequence of digits to be simply replaced with an appropriate sequence of
digits from the other number base.
When possible, the replacement strategy offers considerable speed gains over
strategies that employ arbitraryprecision arithmetic as there is no need
to calculate anything.
Note the replacement conversion strategy can always convert fractions
accurately. Setting the precision for ReplaceConverter has no effect at all
on the conversion results.

Riimu\Kit\BaseConversion\ReplaceConverter
implements
Riimu\Kit\BaseConversion\Converter
Methods summary
public

#
__construct( Riimu\Kit\BaseConversion\NumberBase $source, Riimu\Kit\BaseConversion\NumberBase $target )
Create new instance of ReplaceConverter.
Create new instance of ReplaceConverter.
ReplaceConverter only supports number base combinations that have a
common root or if the target base is nth root of the source base. In
addition, due to using string replacement, any number base that has
conflicting string digits are not supported.
Parameters
 $source
 Number base used by the provided numbers
 $target
 Number base used by the returned numbers
Throws

public

#
setPrecision( integer $precision )
Sets the precision for inaccurate fraction conversions.
Sets the precision for inaccurate fraction conversions.
The fractions cannot always be accurately converted from base to another,
since they may represent a fraction that cannot be represented in another
number base. The precision value is used to determine the number of
digits in the fractional part, if the number cannot be accurately
converted or if it is not feasible to determine that.
If the precision is positive, it defines the maximum number of digits in
the fractional part. If the value is 0, the converted number will have
at least as many digits in the fractional part as it takes to represent
the number in the same accuracy as the original number. A negative number
will simply increase the number of digits.
Note that the fractional part may have fewer digits than what is required
by the precision if it can be accurately represented using fewer digits.
Parameters
 $precision
 Precision used for inaccurate conversions.
Implementation of

public
array

#
convertInteger( array $number )
Converts the integer part of a number.
Converts the integer part of a number.
The integer part should be provided as an array of digits with least
significant digit first. Any invalid digit in the array will cause an
exception to be thrown. The return value will be a similar array of
digits, except converted to the target number base.
Parameters
 $number
 Array of digits representing the integer part
Returns
array Digits for the converted number
Throws
Implementation of

public
array

#
convertFractions( array $number )
Converts the fractional part of a number.
Converts the fractional part of a number.
The fractional part should be provided as an array of digits with least
significant digit first. Any invalid digit in the array will cause an
exception to be thrown. The return value will be a similar array of
digits, except converted to the target number base.
Parameters
 $number
 Array of digits representing the fractional part
Returns
array Digits for the converted number
Throws
Implementation of
