- How do I convert a decimal number to binary in a spreadsheet?
- Use DEC2BIN with the decimal number as the first argument. For example, =DEC2BIN(255) returns 11111111. To pad the result to a specific width, add the places parameter: =DEC2BIN(255,16) produces 0000000011111111 in 16-bit format.
- What is the range of numbers DEC2BIN can convert?
- DEC2BIN handles signed 10-bit integers, supporting the range -512 to 511. Numbers outside this range produce a #NUM! error. For larger numbers, use DEC2HEX (base-16) or DEC2OCT (base-8), or break large numbers into smaller parts before converting.
- Can DEC2BIN handle negative numbers?
- Yes, DEC2BIN supports negative integers from -512 to -1, representing them in two's complement binary form. For example, =DEC2BIN(-1) returns 1111111111 (ten 1s), which is the two's complement representation of -1 in 10-bit binary.
- How do I pad binary output with leading zeros?
- Use the places parameter to specify the desired bit width. For example, =DEC2BIN(5,8) returns 00000101 instead of 101. This ensures all converted values display at the same width, which is essential for consistent formatting when exporting data or creating reports.