dec2base
Convert decimal number to another base.
📝Syntax
R = dec2base(D, B)
R = dec2base(D, B, N)
📥Input Arguments
Parameter Description
D a nonnegative integer smaller than the value returned by flintmax, or a negative value of a signed integer class (int8, int16, int32, int64).
B an integer value [2, 36].
N an integer value. number of digits.
📤Output Arguments
Parameter Description
R result of dec2base: char array.
📄Description

dec2base converts decimal number to another base.

values are cached to speed up next computationdec2base([], 2) to clear cache.

A negative value of a signed integer class is converted using the two's complement representation over the native bit width of the type (8, 16, 32 or 64 bits), so dec2base(int8(-1), 16) returns 'FF'.

💡Examples
X = [65535 128; 1 0]
Y = dec2base(X, 2)
Y = dec2base(X, 2, 26)
Y = dec2base(int8(-1), 16)
🔗See Also
base2dec
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub