Counts the number of significant digits of $val.
Assumes a consistent internal state (without zeros at the end or the start).

@param  Decimal $val
@param  Decimal $abs $val->abs()
@return int
492603
private static function countSignificativeDigits(Decimal $val, Decimal $abs): int
    {
        return \strlen($val->value) - (
            ($abs->comp(DecimalConstants::One()) === -1) ? 2 : \max($val->scale, 1)
        ) - ($val->isNegative() ? 1 : 0);
    }
673895
public static int count(float[] array, float val) {
        int count = 0;
        for (int i=0; i<array.length; i++) {
            if (array[i] == val) {
                count++;
            }
        }
        return count;
    }
1055075
public static function size($val, $min = null, $max = null): bool
    {
        if (!\is_int($val)) {
            if (\is_string($val)) {
                $val = Helper::strlen(\trim($val));
            } elseif (\is_array($val)) {
                $val = \count($val);
            } else {
                return false;
            }
        }

        return self::integer($val, $min, $max);
    }
378306
public function Add( $val )
	{
		$value = $val instanceof DecimalValue ? $val : Convert::ToDecimal( $val );
		return new DecimalValue( bcadd( $this->_value, $value->getValue(), max( $this->getScale(), $this->scale( $value ) ) ) );
	}
1004922
protected function IDiv( $val )
	{
		$numerator = $this->_value;
		$denominator = $val->getValue();

		if ( $denominator == 0 )
			throw XPath2Exception::withErrorCode( "FOAR0001", Resources::FOAR0001 );

		if ( is_nan( $denominator ) )
			throw XPath2Exception::withErrorCode( "FOAR0002", Resources::FOAR0002 );

		if ( is_nan( $numerator ) || is_infinite( $numerator ) )
			throw XPath2Exception::withErrorCode( "FOAR0002", Resources::FOAR0002 );

		return Integer::FromValue( Convert::ToDecimal( $numerator / $denominator )->getIntegerPart() );
	}
1364887
public function numToBinary($value)
    {
        $saved_object_count = $this->writtenObjectCount++;

        $val = "";
        if (intval($value) == $value && !is_float($value) && strpos($value, '.') === false) {
            $val = $this->intToBinary($value);
        } else {
            $val = $this->realToBinary($value);
        }

        $this->objectTable[$saved_object_count] = $val;
        return $saved_object_count;
    }
281667
public static function length($val, $min, $max = null)
    {
        return isset($val[$min - 1]) && (null === $max || !isset($val[$max]));
    }
1053382
public static function lengthSort($val_1, $val_2)
    {
        // initialize the return value to zero
        $retVal = 0;

        // compare lengths
        $firstVal = strlen($val_1);
        $secondVal = strlen($val_2);

        if ($firstVal > $secondVal) {
            $retVal = 1;
        } elseif ($firstVal < $secondVal) {
            $retVal = -1;
        }

        return $retVal;
    }
269052
public static function convertToInt($val, array $valueSet)
    {
        if ($val === null) {

            return 0;
        }
        if (!is_array($val)) {
            $val = [$val];
        }
        $bitValueArr = array_pad([], count($valueSet), '0');
        foreach ($val as $value) {
            if (!in_array($value, $valueSet)) {
                throw new SetColumnConverterException(sprintf('Value "%s" is not among the valueSet', $value), $value);
            }
            $bitValueArr[array_search($value, $valueSet)] = '1';
        }
        
        return base_convert(implode(array_reverse($bitValueArr)), 2, 10);
    }
947836
public static function integer($val)
    {
        if (\is_array($val)) {
            return \array_map(self::class . '::integer', $val);
        }

        return (int)\filter_var($val, \FILTER_SANITIZE_NUMBER_INT);
    }
361630
public static BigDecimal bd(final String val) {
        return val != null && val.length() > 0 ? new BigDecimal(val) : null;
    }
1359665
public static final int[] getBitsSet(final long val) {
    long tmp = val;
    int[] retVal = new int[Long.bitCount(val)];
    for (int i = 0; i < retVal.length; i++) {
      retVal[i] = Long.numberOfTrailingZeros(tmp);
      tmp = tmp ^ Long.lowestOneBit(tmp);
    }
    return retVal;
  }
1084519
public void increment(double val) {
        if (!enabled)
            return;

        lastSampleTime = System.currentTimeMillis();
        if (!sync) {
            count += val;
        } else {
            synchronized (this) {
                count += val;
            }
        }
    }
753021
protected function getValueType($val)
    {
        $type = 'String';
        if ($this->auto_convert_types === true && is_numeric($val)) {
            $type = 'Number';
        }

        return $type;
    }
273800
public static function isLuhn($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        $_num = substr($val, 0, strlen($val)-1);
        return (bool) (intval($val) == intval($_num.self::getLuhnKey($_num)));
    }
200631
protected function validate_point($val) {
        if (empty($val)) {
            return false;
        }
        $maxgrade = (int)get_config('core', 'gradepointmax');
        $isintlike = ((string)(int)$val === $val) ? true : false;
        return ($isintlike === true && $val > 0 && $val <= $maxgrade) ? true : false;
    }
1018200
function getDigitCount(value) {
  let result;

  if (value === 0) {
    result = 1;
  } else {
    result = Math.floor(new Decimal(value).abs().log(10)
      .toNumber()) + 1;
  }

  return result;
}