Get the Verification Digit from a given number

@internal
@param int $num
@return int|string
331237
public static function getVd(int $num)
    {
        $i = 2;
        $sum = 0;

        foreach (array_reverse(str_split($num)) as $v) {
            if ($i === 8) $i = 2;
            $sum += $v * $i;
            ++$i;
        }

        $dig = 11 - ($sum % 11);

        if ($dig === 11) $dig = 0;
        if ($dig === 10) $dig = 'K';

        return $dig;
    }
930793
protected function toNumber($value)
    {
        if (is_numeric($value)) {
            return $value + 0; // cast to number
        }
        if (is_bool($value) || is_null($value)) {
            return (int) $value;
        }
        if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
            return $this->toNumber(reset($value));
        }

        return $value;
    }
496311
public function getArg($num)
    {
        return isset($this->args[$num]) ? $this->args[$num] : null;
    }
36822
public function topByPercent($num)
    {
        $count = $this->countData();
        return $this->top(round($num*$count/100));
    }
1096820
public function TryParseDouble( &$num )
	{
		if ( ! is_null( $this->_doubleValue ) )
		{
			$num = (double)$this->_doubleValue;
			return true;
		}
		if ( $this->CanBeNumber() )
		{
			if ( is_nan( $this->Value ) || $this->Value == "NAN" )
			{
				$num = NAN;
				$this->_doubleValue = $num;
				return true;
			}
			else if ( $this->Value == INF || $this->Value == "INF" )
			{
				$num = INF;
				$this->_doubleValue = $num;
				return true;
			}
			else if ( $this->Value == -INF || $this->Value == "-INF" )
			{
				$num = -INF;
				$this->_doubleValue = $num;
				return true;
			}
			else
			{
				$locale = \Collator::create( null )->getLocale( \Locale::VALID_LOCALE );
				$fmt = new \NumberFormatter( $locale, \NumberFormatter::DECIMAL );
				$num = $fmt->parse( $this->Value );
				if ( $num )
				{
					if ( $num == 0 ) $num = 0.0;
					$this->_doubleValue = $num;
					return true;
				}
			}
		}

		$num = 0.0;
		$this->_doubleValue = $num;
		return false;
	}
308625
private function splitNumber($num)
    {
        if (is_string($num)) {
            $ret = array();

            $strlen = strlen($num);
            $first  = substr($num, 0, $strlen%3);

            preg_match_all('/\d{3}/', substr($num, $strlen%3, $strlen), $m);

            $ret =& $m[0];
            if ($first) {
                array_unshift($ret, $first);
            }
            return $ret;
        }

        return explode(' ', number_format($num, 0, '', ' ')); // a faster version for integers
    }
963994
public static function checkDigitOurNumberAlgorithm($our_number, $base = 9)
    {
        $digit = Utils\Validation::mod11($our_number, $base);

        $digit = ($digit > 1)
            ? $digit - 11
            : 0;

        return abs($digit);
    }
939428
public function D2B($num)
    {
        $this->preOpMethodParamsCheck(array($num));

        /* Make sure that we're dealing with a decimal number. */
        $num = $this->decodeHex($num);

        try {

            $bin = '';

            while ($this->math->comp($num, '0') > 0) {
                switch ($this->math->mod($num, '2')) {
                    case '1':
                        $bin .= '1';
                        break;
                    default:
                        $bin .= '0';
                        break;
                }

                $num = $this->math->div($num, '2');
            }

            return $bin;

        } catch (\Exception $e) {
            throw $e;
        }
    }
334475
private static function removeTrailingZeros($num)
    {
        // Only do this if number has a decimal value.
        if (strstr($num, '.')) {
            $num  = rtrim($num, '0');
            $last = substr($num, strlen($num) - 1, 1) == '.';
            $num  = $last ? substr($num, 0, strlen($num) - 1) : $num;

            return $num;
        } else {
            // No decimal value, don't modify number
            return $num;
        }
    }
832975
public static function upperAlpha(int $num): string
    {
        $num--;
        $alpha = '';

        while ($num >= 0) {
            $ascii = ($num % 26) + 65;
            $alpha = chr($ascii) . $alpha;

            $num = (int)($num / 26) - 1;
        }

        return $alpha;
    }
310394
public static function lowerRoman(int $num): string
    {
        $roman = static::upperRoman($num);

        return StringHelper::toLowerCase($roman);
    }
946794
private static function utf8($num) {
    if ($num <=     0x7F) return chr($num);
    if ($num <=    0x7FF) return chr(($num >>  6) + 192) . chr(( $num        & 63) + 128);
    if ($num <=   0xFFFF) return chr(($num >> 12) + 224) . chr((($num >>  6) & 63) + 128) . chr(( $num       & 63) + 128);
    if ($num <= 0x1FFFFF) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
    return '';
  }
139373
public static function ceil($num, int $precision=0) {
		ref\format::ceil($num, $precision);
		return $num;
	}
583032
public function getFD($num) {
		$folders = [
			'/proc/self/fd',
			'/dev/fd'
		];
		foreach ($folders as $folder) {
			if (file_exists($folder)) {
				return $folder . '/' . $num;
			}
		}
		throw new Exception('Cant find file descriptor path');
	}
1212943
static function hebrewNumeral( $num ) {
		static $table = array(
			array( '', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י' ),
			array( '', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק' ),
			array( '', 'ק', 'ר', 'ש', 'ת', 'תק', 'תר', 'תש', 'תת', 'תתק', 'תתר' ),
			array( '', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י' )
		);

		$num = intval( $num );
		if ( $num > 9999 || $num <= 0 ) {
			return $num;
		}

		$s = '';
		for ( $pow10 = 1000, $i = 3; $i >= 0; $pow10 /= 10, $i-- ) {
			if ( $num >= $pow10 ) {
				if ( $num == 15 || $num == 16 ) {
					$s .= $table[0][9] . $table[0][$num - 9];
					$num = 0;
				} else {
					$s .= $table[$i][intval( ( $num / $pow10 ) )];
					if ( $pow10 == 1000 ) {
						$s .= "'";
					}
				}
			}
			$num = $num % $pow10;
		}
		if ( strlen( $s ) == 2 ) {
			$str = $s . "'";
		} else  {
			$str = substr( $s, 0, strlen( $s ) - 2 ) . '"';
			$str .= substr( $s, strlen( $s ) - 2, 2 );
		}
		$start = substr( $str, 0, strlen( $str ) - 2 );
		$end = substr( $str, strlen( $str ) - 2 );
		switch( $end ) {
			case 'כ':
				$str = $start . 'ך';
 				break;
			case 'מ':
				$str = $start . 'ם';
 				break;
			case 'נ':
				$str = $start . 'ן';
 				break;
			case 'פ':
				$str = $start . 'ף';
 				break;
			case 'צ':
				$str = $start . 'ץ';
 				break;
 		}
 		return $str;
	}
53915
public function eq($num) {
        if (!$this->_isValid) {
            return $this;
        }

        if ($this->_unsafeVar != $num) {
            $this->_isValid = false;
        }
        return $this;
    }
495328
protected function toWords($num)
    {
        $return = '';

        if ($num === 0) {
            return BelgianDictionary::$zero;
        }

        if ($num < 0) {
            $return = BelgianDictionary::$minus . BelgianDictionary::$wordSeparator;
            $num *= -1;
        }

        $numberGroups = $this->numberToTripletsConverter->convertToTriplets($num);
        $sizeOfNumberGroups = count($numberGroups);

        foreach ($numberGroups as $i => $number) {
            // what is the corresponding exponent for the current group
            $pow = $sizeOfNumberGroups - $i;

            // skip processment for empty groups
            if ($number != '000') {
                if ($number != 1 || $pow != 2) {
                    $return .= $this->showDigitsGroup(
                        $number,
                        $i + 1 == $sizeOfNumberGroups || $pow > 2
                    ) . BelgianDictionary::$wordSeparator;
                }
                $return .= BelgianDictionary::$exponent[($pow - 1) * 3];
                if ($pow > 2 && $number > 1) {
                    $return .= BelgianDictionary::$pluralSuffix;
                }
                $return .= BelgianDictionary::$wordSeparator;
            }
        }

        return rtrim($return, BelgianDictionary::$wordSeparator);
    }