Converts an integer number (1 based) to a roman numeral

@param int $int  The number to convert

@return String   The roman numeral
@access protected
15760
protected function int2roman($int)
    {
        $lookup = array(
            '1000'  => 'M',
            '900'   => 'CM',
            '500'   => 'D',
            '400'   => 'CD',
            '100'   => 'C',
            '90'    => 'XC',
            '50'    => 'L',
            '40'    => 'XL',
            '10'    => 'X',
            '9'     => 'IX',
            '5'     => 'V',
            '4'     => 'IV',
            '1'     => 'I',
        );

        $roman = '';
        foreach ($lookup as $max => $letters) {
            while ($int >= $max) {
                $roman .= $letters;
                $int -= $max;
            }
        }

        return $roman;
    }
622525
private String getRomanNumber(int num) {
    String roman = "";  // The roman numeral.
    int N = num;        // N represents the part of num that still has
    //   to be converted to Roman numeral representation.
    for (int i = 0; i < numbers.length; i++) {
      while (N >= numbers[i]) {
        roman += letters[i];
        N -= numbers[i];
      }
    }
    return roman;
  }
1155466
def int_to_roman(num):
    
    conv = (
        ("M", 1000),
        ("CM", 900),
        ("D", 500),
        ("CD", 400),
        ("C", 100),
        ("XC", 90),
        ("L", 50),
        ("XL", 40),
        ("X", 10),
        ("IX", 9),
        ("V", 5),
        ("IV", 4),
        ("I", 1)
    )
    roman = ""
    i = 0
    while num > 0:
        while conv[i][1] > num:
            i += 1
        roman += conv[i][0]
        num -= conv[i][1]
    return roman
229355
function _convertNumber($num)
    {
        // Integer in the range 0..2**16-1
        if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) {
            return pack("Cv", $this->ptg['ptgInt'], $num);
        } else { // A float
            if ($this->_byte_order) { // if it's Big Endian
                $num = strrev($num);
            }
            return pack("Cd", $this->ptg['ptgNum'], $num);
        }
    }
85485
def _int_to_roman(number):
    """"""
    roman_conv = [(10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I")]

    result = []
    for (arabic, roman) in roman_conv:
        (factor, number) = divmod(number, arabic)
        result.append(roman * factor)
        if number == 0:
            break
    return "".join(result)
192971
public static function toInt($value)
    {
        if (!static::is($value)) {
            throw new \InvalidArgumentException(
                "The \$value parameter must be numeric (or string representing a big number)."
            );
        }

        if (is_int($value)) {
            return $value;
        } elseif (is_float($value)) {
            return (int)$value;
        }

        if (($decimal = Str::pos($value, '.')) !== false) {
            $value = Str::sub($value, 0, (int)$decimal);
        }

        return $value;
    }
662789
public static function toInt($value)
    {
        $letter_signs = array('P', 'M');
        $numeric_signs = array('', '-');

        $value_numeric = str_replace($letter_signs, $numeric_signs, $value);

        if (preg_match('#^[\-0-9]#', $value_numeric)) {
            return intval($value_numeric);
        } else {
            return;
        }
    }
349021
public function toHex($integer)
    {
        if (!$integer instanceof BigNumber) {
            $integer = new BigNumber($integer);
        }

        return BigNumber::convertFromBase10($integer, 16);
    }
333522
private function toBinary(string $number) : string
    {
        $result = '';

        while ($number !== '0') {
            [$number, $remainder] = $this->divQR($number, '256');
            $result .= \chr((int) $remainder);
        }

        return \strrev($result);
    }
534996
private static function encodeInteger($integer)
    {
        if ($integer >= 0 && $integer < pow(2, 7)) {
            // positive fixnum: 7-bit positive integer
            // 0XXXXXXX
            return pack('H*', str_pad(dechex($integer), 2, 0, STR_PAD_LEFT));
        } elseif ($integer < 0 && abs($integer) < pow(2, 5)) {
            // negative fixnum: 5-bit negative integer
            // 111YYYYY
            return pack('H*', dechex(bindec(11100000) + $integer));
        }

        if ($integer >= 0) {
            $prefixes = array(8 => 0xcc00, 16 => 0xcd0000, 32 => 0xce00000000, 64 => 0xcf);
        } else {
            $prefixes = array(8 => 0xd000, 16 => 0xd10000, 32 => 0xd200000000, 64 => 0xd3);
        }

        // For each step the max size increases.
        foreach (array(8, 16, 32) as $power) {
            if ($integer < pow(2, $power)) {
                return pack('H*', dechex($prefixes[$power] + $integer));
            }
        }

        // 0x** ZZZZZZZZ ZZZZZZZZ ZZZZZZZZ ZZZZZZZZ ZZZZZZZZ ZZZZZZZZ ZZZZZZZZ ZZZZZZZZ
        return pack('H*', dechex($prefixes[64]).str_pad(dechex($integer), 16, '0', STR_PAD_LEFT));
    }
821517
private function encodeNumber($num)
    {
        $encodeString = '';

        while ($num >= 0x20) {
            $nextValue = (0x20 | ($num & 0x1f)) + 63;
            $encodeString .= chr($nextValue);
            $num >>= 5;
        }
        $finalValue = $num + 63;
        $encodeString .= chr($finalValue);
        return $encodeString;
    }
791939
public static function encode($num)
    {
        $str = '';
        while ($num > 0) {
            $str = self::ALPHABET[($num % self::BASE)] . $str;
            $num = (int)($num / self::BASE);
        }
        return $str;
    }
995818
public static function fromNumber($number)
    {
        if (is_float($number)) {
            return self::fromString(sprintf('%.14F', $number));
        }

        if (is_int($number)) {
            return new self($number);
        }

        if (is_string($number)) {
            return self::fromString($number);
        }

        throw new \InvalidArgumentException('Valid numeric value expected');
    }
282031
public function getErrorName($int)
    {
        if (!$this->_loaded) {
            $this->load();
        }
        if (!isset($this->errorNames[$int])) {
            return "[Error: $int]";
        }
        return $this->errorNames[$int];
    }
805320
public static function convertId($id)
    {
        if (strlen($id) === 17) {
            $converted = substr($id, 3) - 61197960265728;
        } else {
            $converted = '765' . ($id + 61197960265728);
        }
        return (string)$converted;
    }
773853
public static function fromInt($int){
		
		if(!\is_int($int)){
			throw new \InvalidArgumentException('$int must be an integer');
		}
		
		$flags = new static();
		
		foreach(static::getEnumValues() as $const){			
			if(($int & $const) === $const){
				$flags->addFlag($const);
			}
		}

		return $flags;
		
	}
666885
public static function toJapaneseNumeral($number, $type = self::NUMERAL_KANJI)
    {
        // Return fast on zero
        if ($number == 0) {
            if ($type == self::NUMERAL_READING) {
                return 'zero';
            } else {
                return '〇';
            }
        }
        $separator = '';
        switch ($type) {
            case self::NUMERAL_KANJI:
                $mapPowersOfTen = self::$mapPowersOfTenKanji;
                $mapDigits = self::$mapDigitsKanji;
                break;
            case self::NUMERAL_KANJI_LEGAL:
                $mapPowersOfTen = self::$mapPowersOfTenKanjiLegal;
                $mapDigits = self::$mapDigitsKanjiLegal;
                break;
            case self::NUMERAL_READING:
                $mapPowersOfTen = self::$mapPowersOfTenReading;
                $mapDigits = self::$mapDigitsReading;
                $separator = ' ';
                break;
            default:
                throw new Exception('Unknown type');
        }
        $exponent = strlen($number) - 1;
        if ($exponent > 4) {
            $exponentRemainder = $exponent % 4;
            $closestExponent = $exponent - $exponentRemainder;
            $power = pow(10, $closestExponent);
            $remainder = bcmod($number, $power);
            $roundPart = $number - $remainder;
            $multiplier = (int)(($number - $remainder) / $power);
            if ($type != self::NUMERAL_READING || !self::getReadingException($roundPart)) {
                $result = self::toJapaneseNumeral($multiplier, $type) . $separator . $mapPowersOfTen[$closestExponent];
            } else {
                $result = self::getReadingException($roundPart);
            }
            if ($remainder != 0) {
                $result .= rtrim($separator . self::toJapaneseNumeral($remainder, $type));
            }
            return $result;
        } else {
            $result = '';
            while ($exponent > 0) {
                $power = pow(10, $exponent);
                $remainder = bcmod($number, $power);
                $roundPart = $number - $remainder;
                $multiplier = (int)(($number - $remainder) / $power);
                if ($type != self::NUMERAL_READING || !self::getReadingException($roundPart)) {
                    if ($multiplier != 1 || $exponent == 4) {
                        $result .= $mapDigits[$multiplier] . $separator;
                    }
                    $result .= $mapPowersOfTen[$exponent] . $separator;
                } else {
                    $result .= self::getReadingException($roundPart) . $separator;
                }
                $number = $remainder;
                $exponent = strlen($number) - 1;
            }
            if ($number != 0) {
                $result .= $mapDigits[$number];
            }
            return $result;
        }
    }