src/Helpers/Number.php
static public function getDivisionRange($numerator, $denominator, $numeratorPrecision, $denominatorPrecision)
    {
        // The actual value can be half the precision lower or higher.
        // To err on the save side, we take 60% of it (instead of 50%).
        $numeratorHalfRange = 0.6 * (float) $numeratorPrecision;
        $denominatorHalfRange = 0.6 * (float) $denominatorPrecision;

        // The min values should be closer to 0 then the value.
        // The max values should be further from 0 then the value.
        if ($numerator < 0.0) {
            $numeratorHalfRange = -$numeratorHalfRange;
        }
        $minNumerator = (float) $numerator - $numeratorHalfRange;
        $maxNumerator = (float) $numerator + $numeratorHalfRange;

        if ($denominator < 0.0) {
            $denominatorHalfRange = -$denominatorHalfRange;
        }
        $minDenominator = (float) $denominator - $denominatorHalfRange;
        $maxDenominator = (float) $denominator + $denominatorHalfRange;

        // We get the min value of the division by dividing the minimum numerator by
        // the maximum denominator and vice versa.
        $min = $minNumerator / $maxDenominator;
        $max = $maxNumerator / $minDenominator;
        $calculated = $numerator / $denominator;

        return array('min' => $min, 'calculated' => $calculated, 'max' => $max);
    }
static public function getDivisionRange($numerator, $denominator, $numeratorPrecision, $denominatorPrecision)
    {
        // The actual value can be half the precision lower or higher.
        // To err on the save side, we take 60% of it (instead of 50%).
        $numeratorHalfRange = 0.6 * (float) $numeratorPrecision;
        $denominatorHalfRange = 0.6 * (float) $denominatorPrecision;

        // The min values should be closer to 0 then the value.
        // The max values should be further from 0 then the value.
        if ($numerator < 0.0) {
            $numeratorHalfRange = -$numeratorHalfRange;
        }
        $minNumerator = (float) $numerator - $numeratorHalfRange;
        $maxNumerator = (float) $numerator + $numeratorHalfRange;

        if ($denominator < 0.0) {
            $denominatorHalfRange = -$denominatorHalfRange;
        }
        $minDenominator = (float) $denominator - $denominatorHalfRange;
        $maxDenominator = (float) $denominator + $denominatorHalfRange;

        // We get the min value of the division by dividing the minimum numerator by
        // the maximum denominator and vice versa.
        $min = $minNumerator / $maxDenominator;
        $max = $maxNumerator / $minDenominator;
        $calculated = $numerator / $denominator;

        return array('min' => $min, 'calculated' => $calculated, 'max' => $max);
    }
static public function getDivisionRange ( $ numerator , $ denominator , $ numeratorPrecision , $ denominatorPrecision ) { // The actual value can be half the precision lower or higher. // To err on the save side, we take 60% of it (instead of 50%). $ numeratorHalfRange = 0.6 * ( float ) $ numeratorPrecision ; $ denominatorHalfRange = 0.6 * ( float ) $ denominatorPrecision ; // The min values should be closer to 0 then the value. // The max values should be further from 0 then the value. if ( $ numerator < 0.0 ) { $ numeratorHalfRange = - $ numeratorHalfRange ; } $ minNumerator = ( float ) $ numerator - $ numeratorHalfRange ; $ maxNumerator = ( float ) $ numerator + $ numeratorHalfRange ; if ( $ denominator < 0.0 ) { $ denominatorHalfRange = - $ denominatorHalfRange ; } $ minDenominator = ( float ) $ denominator - $ denominatorHalfRange ; $ maxDenominator = ( float ) $ denominator + $ denominatorHalfRange ; // We get the min value of the division by dividing the minimum numerator by // the maximum denominator and vice versa. $ min = $ minNumerator / $ maxDenominator ; $ max = $ maxNumerator / $ minDenominator ; $ calculated = $ numerator / $ denominator ; return array ( 'min' => $ min , 'calculated' => $ calculated , 'max' => $ max ) ; }
Returns the range within which the result of the division should fall given
the precision range for the 2 numbers to divide.

@param float $numerator
@param float $denominator
@param float $numeratorPrecision
The precision used when rounding the number. This means that the
original numerator will not differ more than half of this in any
direction.
@param float $denominatorPrecision
The precision used when rounding the number. This means that the
original denominator will not differ more than half of this in any
direction.

@return array
Array of floats with keys min, max and calculated.
Returns the range within which the result of the division should fall given the precision range for the 2 numbers to divide .