Converts a decimal number to binary.
DEC2BIN(number, numdigits)
returns a binary number as text, given the decimal number, which must be between -512 and 511 inclusive, and may be text or a number.
The output is a binary number with up to ten bits in two's complement representation; positive numbers are 0 to 111111111 (nine bits representing 0 to 511 decimal) and negative numbers 1111111111 to 1000000000 (ten bits representing -1 to -512 decimal).
numdigits is an optional number specifying the number of digits to return.
DEC2BIN(9)
returns 1001 as text.
DEC2BIN("9")
returns 1001 as text. DEC2BIN will accept a decimal number given as text.
DEC2BIN(9, 8)
returns 00001001 as text. Leading zeroes have been added to make 8 diigts.
DEC2BIN(-2)
returns 1111111110 as text.
Let's imagine a scenario where a digital artist is working with a graphics tablet. The tablet's pressure sensor can detect 256 different levels of pressure, from 0 (no pressure) to 255 (maximum pressure). The tablet's internal processor needs to convert this decimal pressure value into a binary number to send to the computer. The computer then uses this binary data to determine the thickness or opacity of the brush stroke.
Here's how the DEC2BIN function would work:
The DEC2BIN function takes a decimal number and converts it to its binary equivalent. It also requires a parameter for the number of significant bits, which in this case would be 8, since 28=256.
Example:
If the artist applies a medium amount of pressure, the sensor might register a decimal value of 150. The tablet's processor would use the DEC2BIN function to convert this number.
DEC2BIN(150, 8) would return 10010110.
Now, let's consider a few other pressure levels and see how they are converted.
Decimal Pressure (Input) | DEC2BIN(Decimal Pressure, 8) (Output) | Binary Representation | ||
|---|---|---|---|---|
A | B | C | ||
1 | 0 | 00000000 | No pressure | |
2 | 1 | 00000001 | Very light pressure | |
3 | 50 | 00110010 | Light pressure | |
4 | 127 | 01111111 | Moderate pressure | |
5 | 150 | 10010110 | Medium pressure | |
6 | 200 | 11001000 | Heavy pressure | |
7 | 255 | 11111111 | Maximum pressure |
The computer receives these 8-bit binary codes and can then interpret them to adjust the brush properties. For example, a higher binary value (closer to 11111111) would result in a thicker, more opaque line, while a lower value (closer to 00000000) would produce a thinner, more transparent line.
This example demonstrates how the DEC2BIN function is a fundamental operation in digital electronics and computer graphics, enabling the conversion of human-perceptible analog data (pressure) into the digital binary format that computers understand.
PRODUCT & FEATURES
RESOURCES
Terms | Privacy | Spam Policy
© 2026 Zapof