Check if specified number is with in specified range (using BCMath)

@param string $num
@param string $from
@param string $to
@param int $scale
@return bool
963879
public static function BcRange(string $num, string $from, string $to, int $scale = 0): bool
    {
        if (!preg_match('/^[0-9]+(\.[0-9]+)?$/', $num)) {
            return false;
        }

        if (bccomp($num, $from, $scale) !== -1) {
            if (bccomp($num, $to, $scale) !== 1) {
                return true;
            }
        }

        return false;
    }
290468
public function getPartialSum( $from, $to )
	{
		for( $i=$from; $i<=$to; $i++ )
			$sum += $this->getValue( $i );
		return $sum;
	}
1071236
public function convert($amount, $from_currency, $to_currency)
    {
        if ($from_currency === $to_currency) {
            return $amount; // Nothing to convert
        }

        $currency = $this->get($from_currency);
        $target_currency = $this->get($to_currency);

        $exponent = $target_currency['decimals'] - $currency['decimals'];
        $amount *= pow(10, $exponent);

        return $amount * ($currency['conversion_rate'] / $target_currency['conversion_rate']);
    }
1349820
private static void checkRange(int fromIndex, int toIndex) {
		if (fromIndex < 0)
			throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex);
		if (toIndex < 0)
			throw new IndexOutOfBoundsException("toIndex < 0: " + toIndex);
		if (fromIndex > toIndex)
			throw new IndexOutOfBoundsException("fromIndex: " + fromIndex +
					" > toIndex: " + toIndex);
	}
297928
public function relPath($from,$to) {
		$expFrom = explode('/',$from);
		$expTo = explode('/',$to);
		$max=max(count($expFrom),count($expTo));
		$rel = [];
		$base=TRUE;
		for ($i=0;$i<$max;$i++) {
			if ($base && isset($expTo[$i]) && isset($expFrom[$i])
				&& $expTo[$i] === $expFrom[$i])
				continue;
			else
				$base=FALSE;
			if (!empty($expFrom[$i]))
				array_unshift($rel,'..');
			if (!empty($expTo[$i]))
				array_push($rel,$expTo[$i]);
		}
		return implode('/',$rel);
	}
415034
public function equals(Decimal $b, int $scale = null): bool
    {
        self::paramsValidation($b, $scale);

        if ($this === $b) {
            return true;
        } else {
            $cmp_scale = $scale !== null ? $scale : \max($this->scale, $b->scale);

            return (
                \bccomp(
                    self::innerRound($this->value, $cmp_scale),
                    self::innerRound($b->value, $cmp_scale),
                    $cmp_scale
                ) === 0
            );
        }
    }
1248235
public function rename($from, $to): bool
    {
        $key = $this->search($from);

        if (\is_null($key)) {
            return false;
        }

        $this->items[$key] = $this->getKeyword($to)->getSlug();

        return true;
    }
715931
public static function convertMetric( $value, $from, $to, $precision = null ) {
        switch ($from . $to) {
            case 'incm':
                $value *= 2.54;
                break;
            case 'inmm':
                $value *= 25.4;
                break;
            case 'inpt':
                $value *= 72;
                break;
            case 'cmin':
                $value /= 2.54;
                break;
            case 'cmmm':
                $value *= 10;
                break;
            case 'cmpt':
                $value *= 72 / 2.54;
                break;
            case 'mmin':
                $value /= 25.4;
                break;
            case 'mmcm':
                $value /= 10;
                break;
            case 'mmpt':
                $value *= 72 / 25.4;
                break;
            case 'ptin':
                $value /= 72;
                break;
            case 'ptcm':
                $value *= 2.54 / 72;
                break;
            case 'ptmm':
                $value *= 25.4 / 72;
                break;
        }

        if ( !is_null($precision) ) {
            $value = round($value, $precision);
        }

        return $value;
    }
730153
public function getIndexInRangeDate(\Datetime $from = null, \Datetime $to = null)
    {
        $results = [];

        if ($index = $this->getIndex()) {
            foreach ($index as $key => $item) {
                $unserializedItem = $item;
                $createdOn = $unserializedItem['created_on']->format('Y-m-d');
                $from = $from ? $from->format('Y-m-d') : null;
                $to = $to ? $to->format('Y-m-d') : null;
                $firstStatement = ($from) ? $createdOn >= $from : true;
                $secondStatement = ($to) ? $createdOn <= $to : true;

                if ($firstStatement && $secondStatement) {
                    $results[$key] = $item;
                }
            }
        }

        return $results;
    }
1025100
function (value, from) {
    var len = this.length >>> 0;

    from = Number(from) || 0;
    from = Math[from < 0 ? 'ceil' : 'floor'](from);

    if (from < 0) {
      from = Math.max(from + len, 0);
    }

    for (; from < len; from++) {
      if (from in this && this[from] === value) {
        return from;
      }
    }

    return -1;
  }
685398
private static function _validateNumber($num): bool
    {
        if (is_int($num)) {
            return true;
        }
        if (is_string($num) && preg_match('/-?\d+/', $num)) {
            return true;
        }
        return false;
    }
1109105
public function add(Decimal $b, int $scale = null): Decimal
    {
        self::paramsValidation($b, $scale);

        return self::fromString(
            \bcadd($this->value, $b->value, \max($this->scale, $b->scale)),
            $scale
        );
    }
660063
public function isLessThan(Decimal $b, int $scale = null): bool
    {
        return $this->comp($b, $scale) === -1;
    }
1081591
public function between($from, $to)
    {
        if (!is_int($from) && !is_float($from)) {
            throw new InvalidIntOrFloatException('from', $from);
        } elseif (!is_int($to) && !is_float($to)) {
            throw new InvalidIntOrFloatException('to', $to);
        } elseif ($from > $to) {
            throw new NumberNotLessStrictlyException('from', $from, $to);
        }

        if (!is_int($this->value) && !is_float($this->value)) {
            throw new InvalidIntOrFloatException($this->name, $this->value);
        } elseif ($this->value < $from || $this->value > $to) {
            throw new NumberNotBetweenException($this->name, $this->value, $from, $to);
        }

        return $this;
    }
1188360
public static function rangeFromBoundaries($from, $to)
    {
        $result = null;
        $invalid = false;
        foreach (array('from', 'to') as $param) {
            if (!($$param instanceof AddressInterface)) {
                $$param = (string) $$param;
                if ($$param === '') {
                    $$param = null;
                } else {
                    $$param = static::addressFromString($$param);
                    if ($$param === null) {
                        $invalid = true;
                    }
                }
            }
        }
        if ($invalid === false) {
            $result = static::rangeFromBoundaryAddresses($from, $to);
        }

        return $result;
    }
726534
public static function merge(array $to, array $from)
    {
        $args = func_get_args();
        $res = array_shift($args);
        while (!empty($args)) {
            $next = array_shift($args);
            foreach ($next as $k => $v) {
                if (is_integer($k)) {
                    isset($res[$k]) ? $res[] = $v : $res[$k] = $v;
                } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) {
                    $res[$k] = self::merge($res[$k], $v);
                } else {
                    $res[$k] = $v;
                }
            }
        }
        return $res;
    }
1336013
protected static void checkRangeFromTo(int from, int to, int theSize) {
	if (to==from-1) return;
	if (from<0 || from>to || to>=theSize)
		throw new IndexOutOfBoundsException("from: "+from+", to: "+to+", size="+theSize);
}