Number Base & Two's Complement Converter

Convert a value between binary, hexadecimal, decimal and octal at a chosen bit width. See its unsigned and signed (two's complement) interpretations, its two's-complement negation, sign extension, and a bit-by-bit breakdown, the everyday arithmetic of RTL and waveforms.

Results

Unsigned decimal
49,374
Signed decimal (two's comp)
-16,162
Hex
0xC0DE
Binary
0b 1100 0000 1101 1110
Octal
0o140336
Two's-comp negation (-x)
0x3F22 = 16,162 unsigned
Bits set (popcount)
8

Byte breakdown

BitsHexBinaryDec
[15:8]0xC011000000192
[7:0]0xDE11011110222

Notes

This exact result is bookmarkable, the URL contains all your inputs. Need it in a script? Append &format=json (API docs).

About this tool

Fixed-width integers wrap: an N-bit register holds 0 to 2^N-1, and by convention the top bit marks the sign in two's complement, where -x is stored as 2^N - x. That's why reading a bus as signed versus unsigned can flip a number from 49374 to -16162 with no bits changing. This converter shows both interpretations, the two's-complement negation (invert the bits and add one), and flags when a value doesn't fit the width you chose.

Related tools