numpy.base_repr

numpy.base_repr(number, base=2, padding=0)

Return a string representation of a number in the given base system.

Parameters:

number : scalar

The value to convert. Only positive values are handled.

base : int

Convert number to the base number system. The valid range is 2-36, the default value is 2.

padding : int, optional

Number of zeros padded on the left.

Returns:

out : str

String representation of number in base system.

See also

binary_repr
Faster version of base_repr for base 2 that also handles negative numbers.

Examples

>>> np.base_repr(3, 5)
'3'
>>> np.base_repr(6, 5)
'11'
>>> np.base_repr(7, 5, padding=3)
'00012'

Previous topic

numpy.binary_repr

Next topic

numpy.DataSource

This Page

Quick search