base(base, n, [pad])

Convert an integer to a string in the given base, optionally specifying a number of digits to pad to. The base can be specified as either an integer, or as a UInt8 array of character values to use as digit symbols.


julia> base(2, 64)
julia> base(3, 64, 5)
julia> base(10, 42)
julia> base(16, 255)
julia> base(2, 10)
julia> base([UInt8('0'), UInt8('1'), UInt8('2'), UInt8('3'), UInt8('4')], 123, 6)
julia> base(8, 53, 4)
julia> base(16, 1024, 8)

Common mistake example:

julia> base(1, 42)
ERROR: ArgumentError: base 1 must be in the range 2 to 36

In this example, the base 1 is not within the valid range of 2 to 36. The base must be specified within this range to convert the integer to a string representation.

See Also

base, big, bytes2hex, cconvert, complex, convert, dec, hex, hex2bytes, hex2num, oct, oftype, parse, promote, signed, unsafe_convert, unsigned, widen,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: