Stax
Tools

Embedded Number Converter

Convert numbers between hex, decimal, binary, and octal.

0
0x
0b
0o
Binary layout (MSB → LSB)
0
0
0
0
0
0
0
0
7
6
5
4
3
2
1
0
Decimal
0
Hex
0x00
Octal
0o000
Byte count
1 bytes
Byte breakdown (big-endian, MSB first)
Byte 0
0x00
0
8-bit unsigned range: 0255

How the Embedded Number Converter works

The embedded number converter translates values between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) with configurable bit widths of 8, 16, or 32 bits. It displays the two's complement signed value, individual bit positions, and byte breakdown — making it the go-to tool for embedded C developers inspecting microcontroller register values, protocol packet fields, and bit-masked flags.

Binary, hex, octal, and decimal relationships

Each hexadecimal digit represents exactly 4 binary bits (a nibble): 0x0 = 0000, 0xA = 1010, 0xF = 1111. Each octal digit represents exactly 3 binary bits: 0 = 000, 7 = 111. This makes hex and octal compact shorthand for binary values. Decimal has no clean relationship to binary — 0xFF = 255 in decimal, a number that requires bit counting to derive mentally. The converter makes all conversions instant for any of the four bases.

Two's complement for signed integers

Embedded C uses two's complement to represent signed integers. In an 8-bit signed type, 0xFF is not 255 — it is −1. 0x80 is −128 and 0x7F is +127. Understanding two's complement is essential when reading register status fields, ADC readings with sign extension, or serial protocol values that use signed arithmetic. The converter shows both the unsigned and two's complement signed interpretations for any bit width.

Bit masking and register field extraction

Microcontroller peripherals use bit fields within 8, 16, or 32-bit registers. The bit layout view shows each bit numbered from MSB to LSB, letting you identify which bits are set in a register value without mental arithmetic. To check if bit 5 of 0xAB is set: 0xAB = 10101011, bit 5 is 1 (set). The C literal formats — 0x prefix for hex, 0b prefix for binary (GCC extension), and 0 prefix for octal — are shown alongside each representation.

Embedded C literal formats

In embedded C, hexadecimal literals use the 0x prefix: uint8_t flags = 0xA5. Binary literals use 0b in GCC: uint8_t flags = 0b10100101. Octal uses a leading zero: 0245. Type suffixes matter: 0xFFFFFFFFU is unsigned, 0xFFFFFFFFL is long. The converter displays the correct C literal syntax for your value in all four bases, including the appropriate type suffix for 16-bit and 32-bit values.

Frequently asked questions

Why do embedded programmers use hex?
Hexadecimal maps directly onto binary in a compact and readable way — each hex digit represents exactly 4 binary bits (one nibble). This makes it easy to inspect bit patterns in hardware registers, memory addresses, CAN bus frames, UART data, and SPI protocol bytes without counting long strings of 0s and 1s.
What is two's complement?
Two's complement is the universal standard for representing signed (positive and negative) integers in binary hardware. To find the two's complement of a number, invert all its bits and add 1. For an 8-bit signed integer, the range is -128 (0x80) to +127 (0x7F). This representation makes arithmetic circuits simpler because addition and subtraction work identically for both signed and unsigned numbers.
What does 0xFF mean in 8-bit signed vs unsigned?
The hex value 0xFF has different decimal meanings depending on interpretation. In 8-bit unsigned representation, 0xFF equals 255 — the maximum positive value. In 8-bit signed (two's complement) representation, the same 0xFF equals -1. This is a common source of bugs when mixing signed and unsigned types in C/C++ embedded code. This converter displays both interpretations simultaneously when you toggle signed/unsigned mode.

Related tools