Skip to main content
Call Eric:863-698-8266
CURRYCONTROLS.COMControls & Automation Knowledge Hub

PLC & Data

Number Base and Bit Converter

Convert between decimal, hexadecimal, binary, and octal, with the bit pattern shown and the two-complement signed interpretation for 16 and 32 bit words.

Inputs

Results

Decimal (unsigned)
16,384
Decimal (signed, two complement)
16,384
Hexadecimal
0x4000
Binary
0100 0000 0000 0000
Octal
40000
Bits set
14

Bit 0 is the least significant bit.

Percent of full scale
25.000%

Against the 16-bit unsigned maximum

The arithmetic

  1. Parsed "16384" as base 10 = 16,384 decimal
  2. 16-bit pattern: 0100 0000 0000 0000
  3. Sign bit (bit 15) is clear, so the signed value is 16,384

What this does not account for

  • Whether a value reads as signed or unsigned depends on the data type of the tag, not on the bits. The same word is 65535 in a WORD and -1 in an INT.
  • Bit numbering conventions differ between platforms. Some vendors number bits from the most significant end, and some number them within a word rather than within a double word.

How this is calculated

A value entered in any base converts to the others by parsing it to an integer and re-rendering it. In PLC work the signed interpretation matters: the same 16-bit pattern reads as 65535 unsigned and as -1 signed, which is why an analog value can appear as a large positive number in one tag and a negative number in another.

Assumptions built into this calculator

  • Two-complement representation for signed values, which is what every common PLC platform uses.
  • Bit 0 is the least significant bit.

Frequently asked questions

Why does my analog value show as negative?
The raw value has its high bit set and the tag is a signed integer. A 16-bit analog value above 32767 wraps to a negative number in an INT. Either the card range is misconfigured or the value belongs in a DINT.

Direct contact

Have a controls question?

Reach Eric Sullivan directly about anything on this site, a controls or automation topic, or one of his personal projects.