Convert decimal integer to its base-n representation for
returns a base-n representation of the decimal integer
baseStr = dec2base(
D. The output argument
baseStr is a character
array that represents digits using numeric characters, and, when
greater than 10, letters. For example, if
n is 12, the
dec2base represents the numbers 9, 10, and 11 using the characters
B, and represents the
number 12 as the character sequence
Convert Decimal Number
Convert a decimal number to a character vector that represents its value in base 3.
D = fi(23); baseStr = dec2base(D,3)
baseStr = '212'
Convert a decimal number to a character vector that represents its value in base 12.
In this base system, the characters
represent the numbers denoted as
11 in base
D = fi(23); baseStr = dec2base(D,12)
baseStr = '1B'
Specify Number of Digits
Specify the number of base-3 digits that
dec2base returns. If you specify more digits than are required,
dec2base pads the output with leading zeros.
D = fi(23); baseStr = dec2base(D,3,5)
baseStr = '00212'
Convert Upperbound of
Convert the upper bound of a signed
fi object with
100-bit word length to base 36 representation.
baseStr = dec2base(upperbound(fi(,1,100,0)),36)
baseStr = '1PG7OTO50BLAOIQ8FPQ7'
D — Input array
fi array of nonnegative numbers
Input array, specified as a
fi array of nonnegative
D must contain finite integers. If any element of
D has a fractional part, then
produces an error. For example,
dec2base(fi(10.5),8) produces an error.
n — Base of output representation
integer between 2 and 36
Base of output representation, specified as an integer between 2 and 36. For
8, then the output represents
minDigits — Minimum number of digits in output
Minimum number of digits in the output, specified as a positive integer.
Dcan be represented with fewer than
dec2basepads the output with leading zeros.
Dis so large that it must be represented with more than
dec2basereturns the output with as many digits as required.
Design and simulate fixed-point systems using Fixed-Point Designer™.
Slope-bias representation is not supported.