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:
Based on the Excel spreadsheet above, the following DEC2BIN examples would return:
- 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.