The Excel DEC2BIN function converts a decimal number to its binary equivalent.
Syntax: DEC2BIN(number, [places])
The DEC2BIN function syntax has the following arguments:
- Number Required. The decimal integer you want to convert. If number is negative, valid place values are ignored and DEC2BIN returns a 10-character (10-bit) binary number in which the most significant bit is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two’s-complement notation.
-
Places Optional. The number of characters to use. If places is omitted, DEC2BIN uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).
Example: Let’s look at some Excel DEC2BIN function examples and explore how to use the DEC2BIN function as a worksheet function in Microsoft Excel:
Syntax: =DEC2BIN(A2)
Result:
Based on the Excel spreadsheet above, the following DEC2BIN examples would return:
Syntax: =DEC2BIN(A3)
Result: 10
Syntax: =DEC2BIN(A4)
Result: 11
Syntax: =DEC2BIN(A5)
Result: 110
Syntax: =DEC2BIN(A6)
Result: 1100100
Syntax: =DEC2BIN(A7)
Result: 0
Syntax: =DEC2BIN(A8)
Result: 110010
Syntax: =DEC2BIN(A9)
Result: 10010110
Syntax: =DEC2BIN(A10)
Result: 1110011100
Syntax: =DEC2BIN(A11,B11)
Result: 1001
Syntax: =DEC2BIN(A12,B12)
Result: #VALUE!
Syntax: =DEC2BIN(A13,B13)
Result: #NUM!
Syntax: =DEC2BIN(A14,B14)
Result: #NUM!
Syntax: =DEC2BIN(A15,B15)
Result: #NUM!
Note:
- Numbers can be given as argument to the function directly without quotes or cell reference in excel.
- The function doesn’t consider the [places] number in case of a negative decimal number.
- The number must be a valid decimal number between – 512 to + 511.
- If the input [places] number is not an integer, it is truncated by the function.
- The function returns the binary value for the max value of + 511 & minimum value upto – 512 (only integers).
- The function returns the #NUM! Error
- If the input decimal number is less than – 512 or greater than + 511.
-
- If the input number [places] is zero or negative.
- If the input number [places] is not sufficient for the resulting positive binary number.
- The function returns the #VALUE! Error
- If the input number is text or non-numeric.
- If the input [places] number is text or non-numeric.