/** * Calculate the quotient and remainder from a +ve numerator/denominator with no decimals. * @param BigNumber $numerator the numerator to use. * @param BigNumber $denominator the denominator. * @param BigNumber $quotient the return quotien value. * @param BigNumber $remainder the remainder value. * @return boolean success or not. */ protected static function AbsQuotientAndRemainderWithSmallNumbers($numerator, $denominator, &$quotient, &$remainder) { $denominatorLen = count($denominator->_numbers); if ($denominatorLen > self::BIGNUMBER_MAX_NUM_LEN) { return false; } // can we go even faster? If the numbers are smaller than our max int then we can. if (count($numerator->_numbers) > self::BIGNUMBER_MAX_NUM_LEN) { return false; } $n = $numerator->Abs()->ToInt(); $d = $denominator->Abs()->ToInt(); $num = (int) ($n / $d); $mod = $n % $d; $quotient = new BigNumber($num); $remainder = new BigNumber($mod); // clean up the quotient and the remainder. $remainder->PerformPostOperations($remainder->_decimals); $quotient->PerformPostOperations($quotient->_decimals); // success return true; }