public function toBase($base)
    {
        if ($this->normalize()->hasDecimals()) {
            throw new \InvalidArgumentException('Argument number is not an integer');
        }

        // do not mutate, only support positive integers
        $number = ltrim((string) $this, '-');
        if (static::$gmpSupport && $base <= 62) {
            return static::baseConvert($number, 10, $base);
        }

        $result   = '';
        $baseChar = static::getBaseChar($base);
        while (bccomp($number, 0) != 0) { // still data to process
            $rem    = bcmod($number, $base); // calc the remainder
            $number = bcdiv(bcsub($number, $rem), $base);
            $result = $baseChar[$rem] . $result;
        }

        $result = $result ? $result : $baseChar[0];

        return (string) $result;
    }
public function toBase($base)
    {
        if ($this->normalize()->hasDecimals()) {
            throw new \InvalidArgumentException('Argument number is not an integer');
        }

        // do not mutate, only support positive integers
        $number = ltrim((string) $this, '-');
        if (static::$gmpSupport && $base <= 62) {
            return static::baseConvert($number, 10, $base);
        }

        $result   = '';
        $baseChar = static::getBaseChar($base);
        while (bccomp($number, 0) != 0) { // still data to process
            $rem    = bcmod($number, $base); // calc the remainder
            $number = bcdiv(bcsub($number, $rem), $base);
            $result = $baseChar[$rem] . $result;
        }

        $result = $result ? $result : $baseChar[0];

        return (string) $result;
    }
public function toBase ( $ base ) { if ( $ this -> normalize ( ) -> hasDecimals ( ) ) { throw new \ InvalidArgumentException ( 'Argument number is not an integer' ) ; } // do not mutate, only support positive integers $ number = ltrim ( ( string ) $ this , '-' ) ; if ( static :: $ gmpSupport && $ base <= 62 ) { return static :: baseConvert ( $ number , 10 , $ base ) ; } $ result = '' ; $ baseChar = static :: getBaseChar ( $ base ) ; while ( bccomp ( $ number , 0 ) != 0 ) { // still data to process $ rem = bcmod ( $ number , $ base ) ; // calc the remainder $ number = bcdiv ( bcsub ( $ number , $ rem ) , $ base ) ; $ result = $ baseChar [ $ rem ] . $ result ; } $ result = $ result ? $ result : $ baseChar [ 0 ] ; return ( string ) $ result ; }
convert decimal value to any other base bellow or equals to 64

@param int $base

@throws \InvalidArgumentException

@return string
convert decimal value to any other base bellow or equals to 64