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

dec2bin converts decimal number to base 2.

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 dec2bin(int8(-1)) returns '11111111'.

💡Examples
Y = dec2bin(2)
Y = dec2bin(int8(-92), 8)
🔗See Also
dec2basebin2dec
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub