base

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.

Examples

julia> base(2, 64)
1000000
julia> base(3, 64, 5)
02101
julia> base(10, 42)
"42"
julia> base(16, 255)
"FF"
julia> base(2, 10)
"1010"
julia> base([UInt8('0'), UInt8('1'), UInt8('2'), UInt8('3'), UInt8('4')], 123, 6)
"002401"
julia> base(8, 53, 4)
"0065"
julia> base(16, 1024, 8)
"00000400"

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
Details

Checking you are not a robot: