@param int|float $n1
@param int|float $n2
@param bool      $round

@return float
974402
public static function mul($n1, $n2, $round = false)
    {
        $product = bcmul($n1, $n2, self::$scale);

        return $round ? self::round($product) : (float)$product;
    }
422418
public static function sub($num1, $num2)
    {
        if (!static::is($num1) || !static::is($num2)) {
            throw new \InvalidArgumentException("The \$num1 and \$num2 parameters must be numeric.");
        }

        return ($num1 - $num2);
    }
1330212
public static function add($float1, $float2)
    {
        if (!static::is($float1) || !static::is($float2)) {
            throw new \InvalidArgumentException("The \$float1 and \$float2 parameters must be of type float.");
        }

        return ($float1 + $float2);
    }
308668
protected static function c(int $n) : float
    {
        if ($n <= 1) {
            return 1.;
        }
        
        return 2. * (log($n - 1) + M_EULER) - 2. * ($n - 1) / $n;
    }
1332141
public static function cast( $input, $default = null, ?int $precision = null ) {

    $result = null;
    switch( true ) {
      case is_int( $input ) || is_float( $input ):
        $result = $input;
        break;

      case is_bool( $input ):
        $result = $input ? 1 : 0;
        break;

      case Text::is( $input, true ) && strlen( $input ) > 0 && ltrim( $input, '+-,.e0123456789' ) == '':
        $tmp    = floatval( str_replace( ',', '.', $input ) );
        $result = strpos( $input, '.' ) === false && strpos( $input, ',' ) === false ? intval( $tmp ) : $tmp;
        break;
    }

    if( $result === null ) return $default;
    else return $precision === null ? $result : ( $precision === 0 ? intval( $result ) : round( $result, $precision ) );
  }
542938
public static function mathSubtract($decimal1, $decimal2) {
        if (!is_numeric($decimal1)) {
            throw new Exception("decimal1 is not a numeric value: " . $decimal1);
        }

        if (!is_numeric($decimal2)) {
            throw new Exception("decimal2 is not a numeric value: " . $decimal2);
        }

        return round($decimal1 - $decimal2, StaticEb::$roundPrecision);
    }
863325
public static function round($op1, $precision = 0)
    {
        if (self::$_bcmathDisabled) {
            $op1 = round($op1, $precision);
            if (strpos((string) $op1, 'E') === false) {
                return self::normalize(round($op1, $precision));
            }
        }

        if (strpos($op1, 'E') !== false) {
            $op1 = self::floatalize($op1);
        }

        $op1    = trim(self::normalize($op1));
        $length = strlen($op1);
        if (($decPos = strpos($op1, '.')) === false) {
            $op1 .= '.0';
            $decPos = $length;
            $length += 2;
        }
        if ($precision < 0 && abs($precision) > $decPos) {
            return '0';
        }

        $digitsBeforeDot = $length - ($decPos + 1);
        if ($precision >= ($length - ($decPos + 1))) {
            return $op1;
        }

        if ($precision === 0) {
            $triggerPos = 1;
            $roundPos   = -1;
        } elseif ($precision > 0) {
            $triggerPos = $precision + 1;
            $roundPos   = $precision;
        } else {
            $triggerPos = $precision;
            $roundPos   = $precision -1;
        }

        $triggerDigit = $op1[$triggerPos + $decPos];
        if ($precision < 0) {
            // zero fill digits to the left of the decimal place
            $op1 = substr($op1, 0, $decPos + $precision) . str_pad('', abs($precision), '0');
        }

        if ($triggerDigit >= '5') {
            if ($roundPos + $decPos == -1) {
                return str_pad('1', $decPos + 1, '0');
            }

            $roundUp = str_pad('', $length, '0');
            $roundUp[$decPos] = '.';
            $roundUp[$roundPos + $decPos] = '1';

            if ($op1 > 0) {
                if (self::$_bcmathDisabled) {
                    return Zend_Locale_Math_PhpMath::Add($op1, $roundUp, $precision);
                }
                return self::Add($op1, $roundUp, $precision);
            } else {
                if (self::$_bcmathDisabled) {
                    return Zend_Locale_Math_PhpMath::Sub($op1, $roundUp, $precision);
                }
                return self::Sub($op1, $roundUp, $precision);
            }
        } elseif ($precision >= 0) {
            return substr($op1, 0, $decPos + ($precision ? $precision + 1: 0));
        }

        return (string) $op1;
    }
906931
private function compare_float( $a, $b ) {
		$a = number_format( $a, 4 );
		$b = number_format( $b, 4 );
		if ( 0 === $a - $b ) {
			return 0;
		} elseif ( $a - $b < 0 ) {
			return -1;
		} else {
			return 1;
		}
	}
756157
public static function between(
        $latitude1,
        $longitude1,
        $latitude2,
        $longitude2,
        $decimals = 1,
        $unit = 'km'
    ) {
        // define calculation variables
        $theta = $longitude1 - $longitude2;
        $distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2)))
            + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)))
        ;
        $distance = acos($distance);
        $distance = rad2deg($distance);
        $distance = $distance * 60 * 1.1515;

        // unit is km
        if ($unit == 'km') {
            // redefine distance
            $distance = $distance * 1.609344;
        }

        // return with one decimal
        return round($distance, $decimals);
    }
753485
public static function div($float1, $float2)
    {
        if (!static::is($float1) || !static::is($float2)) {
            throw new \InvalidArgumentException("The \$float1 and \$float2 parameters must be of type float.");
        }

        if ($float2 == 0) {
            throw new \InvalidArgumentException("Cannot divide by zero. The \$float2 parameter cannot be zero.");
        }

        return ($float1 / $float2);
    }
1172171
public static function round($arg1, $scale = 0) : string {
		if (!isset($scale)) {
			$scale = self::$scale;
		}
		if ($arg1[0] != '-') {
			return bcadd($arg1, '0.' . str_repeat('0', $scale) . '5', $scale);
		} else {
			return bcsub($arg1, '0.' . str_repeat('0', $scale) . '5', $scale);
		}
	}
796125
function setCupRoundsPerMap($rounds, $multicall = false)
    {
        if (!is_int($rounds)) {
            throw new InvalidArgumentException('rounds = ' . print_r($rounds, true));
        }

        return $this->execute(ucfirst(__FUNCTION__), array($rounds), $multicall);
    }
339710
function(color1, color2) {
		for (var i=0;i<3;i++) {
			for (var j=1;j<arguments.length;j++) {
				color1[i] *= arguments[j][i] / 255;
			}
			color1[i] = Math.round(color1[i]);
		}
		return color1;
	}
1069782
public static function number(float $n, int $precision = 0): string
    {
        return self::$locale->number(round($n, $precision));
    }
462524
public function convert($value, $targetCurrency, $round = true, $valueCurrency = null)
    {
        return $this->getConverter()->convert($value, $targetCurrency, $round, $valueCurrency);
    }
995738
public static function compare_floats($v1, $v2, string $operator = '===', int $precision = 4): bool
  {
    $v1 = round((float)$v1 * pow(10, $precision));
    $v2 = round((float)$v2 * pow(10, $precision));
    switch ($operator ){
      case '===':
        return $v1 === $v2;
      case '==':
        return $v1 == $v2;
      case '>=':
        return $v1 >= $v2;
      case '<=':
        return $v1 <= $v2;
      case '>':
        return $v1 > $v2;
      case '<':
        return $v1 < $v2;
    }
    return false;
  }
98162
protected function toMany(array $units, $decimals = null, $round = true)
    {
        $results = array();
        foreach ($units as $key) {
            $results[$key] = $this->to($key, $decimals, $round);
        }

        return $results;
    }