Converts an integer or `Moontoast\Math\BigNumber` integer representation
into a hexadecimal string representation

@param int|string|BigNumber $integer An integer or `Moontoast\Math\BigNumber`
@return string Hexadecimal string
349021
public function toHex($integer)
    {
        if (!$integer instanceof BigNumber) {
            $integer = new BigNumber($integer);
        }

        return BigNumber::convertFromBase10($integer, 16);
    }
506129
function toHex(bignum) {
      var tmp0 = bignum[0] < 0 ? (bignum[0]>>>0) : bignum[0];
      var tmp1 = bignum[1] < 0 ? (bignum[1]>>>0) : bignum[1];
      return tmp0.toString(16) + tmp1.toString(16);
    }
692276
public static function intBytes($int)
    {
        $intbytes = "";

        if ($int > 0xFFFF) {
            $intbytes = "\x12".pack("N", $int); // 4 byte integer
        } elseif ($int > 0xFF) {
            $intbytes = "\x11".pack("n", $int); // 2 byte integer
        } else {
            $intbytes = "\x10".pack("C", $int); // 8 byte integer
        }

        return $intbytes;
    }
652318
public static function int_to_roman($number) {
        if (!is_integer($number) || $number < 1 || $number > 3999) {
            throw new coding_exception('Only integers between 0 and 3999 can be ' .
                    'converted to roman numerals.', $number);
        }

        return self::$thousands[$number / 1000 % 10] . self::$hundreds[$number / 100 % 10] .
                self::$tens[$number / 10 % 10] . self::$units[$number % 10];
    }
1344398
public function getInteger()
    {
        if (!self::hasBigNumber()) {
            throw new Exception\UnsatisfiedDependencyException(
                'Cannot call ' . __METHOD__ . ' without support for large '
                . 'integers, since integer is an unsigned '
                . '128-bit integer; Moontoast\Math\BigNumber is required'
                . '; consider calling getHex instead'
            );
        }

        $number = \Moontoast\Math\BigNumber::baseConvert(
            $this->getHex(),
            16,
            10
        );

        return new \Moontoast\Math\BigNumber($number);
    }
430219
public function base10($number)
    {
        if (!is_int($number)) {
            throw new \InvalidArgumentException('Expecting integer');
        }

        if ($this->integerPart === '0' && !$this->fractionalPart) {
            return $this;
        }

        $sign = '';
        $integerPart = $this->integerPart;

        if ($integerPart[0] === '-') {
            $sign = '-';
            $integerPart = substr($integerPart, 1);
        }

        if ($number >= 0) {
            $integerPart = ltrim($integerPart, '0');
            $lengthIntegerPart = strlen($integerPart);
            $integers = $lengthIntegerPart - min($number, $lengthIntegerPart);
            $zeroPad = $number - min($number, $lengthIntegerPart);

            return new self(
                $sign.substr($integerPart, 0, $integers),
                rtrim(str_pad('', $zeroPad, '0').substr($integerPart, $integers).$this->fractionalPart, '0')
            );
        }

        $number = abs($number);
        $lengthFractionalPart = strlen($this->fractionalPart);
        $fractions = $lengthFractionalPart - min($number, $lengthFractionalPart);
        $zeroPad = $number - min($number, $lengthFractionalPart);

        return new self(
            $sign.ltrim($integerPart.substr($this->fractionalPart, 0, $lengthFractionalPart - $fractions).str_pad('', $zeroPad, '0'), '0'),
            substr($this->fractionalPart, $lengthFractionalPart - $fractions)
        );
    }
259806
private function numberToNumerals($number, array $numerals)
    {
        $string = '';

        while ($number > 0) {
            foreach ($numerals as $n => $t) {
                if ($number >= $n) {
                    $string .= $t;
                    $number -= $n;
                    break;
                }
            }
        }

        return $string;
    }
902670
protected function pack_int($int) {
        if (PHP_INT_SIZE === 8) {
            $left = 0xffffffff00000000;
            $right = 0x00000000ffffffff;
            $l = ($int & $left) >>32;
            $r = $int & $right;

            return pack('NN', $l, $r);
        } else {
            return pack('NN', 0, $int);
        }
    }
1165729
public function toRoman($number)
    {
        if (($number < self::MIN_VALUE) || ($number > self::MAX_VALUE)) {
            throw new \InvalidArgumentException();
        }

        $romanString = '';

        while ($number > 0) {
            foreach ($this->map as $key => $value) {
                if ($number >= $value) {
                    $romanString .= $key;
                    $number -= $value;
                    break;
                }
            }
        }

        return $romanString;
    }
971824
public static function decimalToAlphanumeric($number, $base = 64, $index = false)
    {
        if (!$base) {
            $base = strlen($index);
        } elseif (!$index) {
            $index = substr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, $base);
        }

        $out = "";

        for ($i = floor(log10($number) / log10($base)); $i >= 0; $i--) { 
            $no = floor($num/pow($base, $i));
            $out = $out.substr($index, $no, 1);
            $number = $number - ($no * pow($base, $i));
        }
        return $out;
    }
929774
public static function toRoman($int)
    {
        if (!is_int($int) || $int < 1 || $int > 3999) {
            throw new \InvalidArgumentException("A roman numeral must be an integer between 1 and 3999, $int given.");
        }

        $roman = '';
        foreach (self::$characters as $number => $character) {
            while ($int >= $number) {
                $roman .= $character;
                $int -= $number;
            }
        }

        return $roman;
    }
380127
private function intToByteString(int $int): string
    {
        $result = [];
        while (0 !== $int) {
            $result[] = chr($int & 0xFF);
            $int >>= 8;
        }
        
        return str_pad(implode(array_reverse($result)), 8, "\000", STR_PAD_LEFT);
    }
660033
public static function integerToOctetString(Integer $num, $mlen = null): OctetString
    {
        $gmp = gmp_init($num->number(), 10);
        $str = gmp_export($gmp, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN);
        if (null !== $mlen) {
            $len = strlen($str);
            if ($len > $mlen) {
                throw new \RangeException("Number is too large.");
            }
            // pad with zeroes
            if ($len < $mlen) {
                $str = str_repeat("\0", $mlen - $len) . $str;
            }
        }
        return new OctetString($str);
    }
255247
protected static function validatePositiveInteger($integer)
    {
        $integer = max(0, (int) $integer);
        if (!$integer) {
            throw new \InvalidArgumentException('Argument number is not valid');
        }

        return (string) $integer;
    }
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');
    }
537615
public static function numericOptions($integers): array
    {
        $array = [];
        foreach ($integers as $integer) {
            if ($integer === -1) {
                $array[$integer] = I18N::translate('All');
            } else {
                $array[$integer] = I18N::number($integer);
            }
        }

        return $array;
    }
1038569
public static function abs($int)
    {
        if (!static::is($int)) {
            throw new \InvalidArgumentException(
                "The \$int parameter must be of type int (or string representing a big int)."
            );
        }

        if (Int::is($int)) {
            return Int::abs($int);
        } else {
            return Str::replace($int, '-', '');
        }
    }