$value) { if (\substr_count($n, (string) $place) != $value) { return false; } } return true; } /** * Is square number? * * @param int $n Number to test * * @return bool * * @since 1.0.0 */ public static function isSquare(int $n) : bool { return \abs(((int) \sqrt($n)) * ((int) \sqrt($n)) - $n) < self::EPSILON; } /** * Count trailing zeros * * @param int $n Number to test * * @return int * * @since 1.0.0 */ public static function countTrailingZeros(int $n) : int { $count = 0; while ($n !== 0) { if (($n & 1) === 1) { break; } ++$count; $n >>= 1; } return $count; } /** * Remap numbers between 0 and X to 0 and 100 * * @param int $number Number to remap * @param int $max Max possible number * @param float $exp Exponential modifier * * @return float * * @since 1.0.0 */ public static function remapRangeExponentially(int $number, int $max, float $exp = 1.0) : float { if ($number > $max) { $number = $max; } $exponent = ($number / $max) * $exp; return (\exp($exponent) - 1) / (\exp($exp) - 1) * 100; } /** * Remap numbers between 0 and X to 0 and 100 * * @param int $number Number to remap * @param int $max Max possible number * * @return float * * @since 1.0.0 */ public static function remapRangeLog(int $number, int $max) : float { if ($number > $max) { $number = $max; } return (\log($number + 1) / \log($max + 1)) * 100; } }