public function base($n)
    {
        self::mustBeInteger($n, 'Base');
        
        if(!$this->_decimal()->zero) {
            throw new \RuntimeException(
                'Cannot convert to another base from non integer value.'
            );
        }


        $n = is_object($n) ? $n->int : $n;

        if (!is_numeric($n) || $n < 2 || $n > 36) {
            throw new \InvalidArgumentException(
                'Base must be an integer or \Malenki\Bah\N value from 2 '
                .'to 36 inclusive.'
            );
        }

        return new S(
            ($this->value < 0 ? '-' : '') . base_convert($this->value, 10, $n)
        );
    }
public function base($n)
    {
        self::mustBeInteger($n, 'Base');
        
        if(!$this->_decimal()->zero) {
            throw new \RuntimeException(
                'Cannot convert to another base from non integer value.'
            );
        }


        $n = is_object($n) ? $n->int : $n;

        if (!is_numeric($n) || $n < 2 || $n > 36) {
            throw new \InvalidArgumentException(
                'Base must be an integer or \Malenki\Bah\N value from 2 '
                .'to 36 inclusive.'
            );
        }

        return new S(
            ($this->value < 0 ? '-' : '') . base_convert($this->value, 10, $n)
        );
    }
public function base ( $ n ) { self :: mustBeInteger ( $ n , 'Base' ) ; if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'Cannot convert to another base from non integer value.' ) ; } $ n = is_object ( $ n ) ? $ n -> int : $ n ; if ( ! is_numeric ( $ n ) || $ n < 2 || $ n > 36 ) { throw new \ InvalidArgumentException ( 'Base must be an integer or \Malenki\Bah\N value from 2 ' . 'to 36 inclusive.' ) ; } return new S ( ( $ this -> value < 0 ? '-' : '' ) . base_convert ( $ this -> value , 10 , $ n ) ) ; }
Converts current number into another base.

This converts current number to another base. Alowed bases are into the
range `[2, 36]`.

$n = new N(2001);
echo $n->base(2); // '11111010001'


You can have negative result too:

$n = new N(-2001);
echo $n->base(2); // '-11111010001'

@see S::$bin Shorthand for base 2
@see S::$oct Shorthand for base 8
@see S::$hex Shorthand for base 16
@see S::$b Another shorthand for base 2
@see S::$o Another shorthand for base 8
@see S::$h Another shorthand for base 16
@param mixed $n Base as integer-like value.
@return S
@throws \RuntimeException If current number is not an integer.
@throws \InvalidArgumentException If given base number is not an
Integer-like value.
Converts current number into another base .