Fixed-width integer representation calculator
Choose signed or unsigned input and a width that is a multiple of eight. The same stored bits are then interpreted both ways and displayed in both byte orders.
Result
- Binary pattern
- 1111111111111110
- Unsigned interpretation
- 65534
- Signed interpretation
- -2
- Big-endian bytes
- FF FE
- Little-endian bytes
- FE FF
Keep value and representation together
At 16 bits, signed -2 has pattern 1111111111111110. Its unsigned interpretation is 65534. Big-endian bytes are FF FE; little-endian bytes are FE FF. Byte order changes the order of whole bytes, while bit order within each displayed byte stays fixed.
Range checks prevent silent wrapping
Widths are 8, 16, 24, 32, 40, 48, 56 or 64 bits. Unsigned inputs range from zero through 2^width − 1. Signed inputs use two’s complement and range from -2^(width − 1) through 2^(width − 1) − 1. Out-of-range values are rejected. This is an integer representation exercise and does not inspect a device or file format.