Data Format Inspector
Paste bytes from a debugger, a logic analyzer or a serial log and see every integer, float, half, bfloat16 and fixed-point reading in both byte orders. Decode a whole C struct with the real padding rules, and check the frame's CRC.
1 · Bytes
2 · Fixed point
Interpretation
Each type read from the offset in each byte order. Small text is the assembled word.
Bit view
3 · Encode a value
Rounding is round-to-nearest-even straight from your decimal digits, so the error shown is exact. Fixed point rounds half away from zero and saturates, like CMSIS-DSP.
Value → bytes
| Type | Stored value | LE bytes | BE bytes | Note |
|---|
IEEE-754 breakdown
Format limits
4 · Struct layout
C-like declarations: fixed-width and plain C types, arrays, pointers, enums, bit-fields (uint8_t mode:3;), CMSIS q15_t/q31_t, _Float16, __bf16.
5 · CRC range
Custom CRC
Struct fields
| Offset | Size | Field | Type | Raw | Value |
|---|
CRC
| Algorithm | Parameters | CRC | On the wire | Check "123456789" |
|---|
6 · Base converter
Conversions
The same bytes, read six ways
Memory holds bytes. A type is only a rule for turning a run of bytes into a number, and the byte order says which byte carries the most significant bits. Read 78 56 34 12 little-endian and you get 0x12345678; read it big-endian and you get 0x78563412. Both are valid numbers, which is why a byte-order mistake rarely crashes. It just produces a plausible wrong value.
CDAB and BADC come from devices that store a 32-bit value as two 16-bit registers. Modbus is big-endian inside each register, but the register order for 32-bit values is not standardized, so many PLCs and meters send the low word first.
IEEE-754 floating point
| Format | Sign/exp/mant | Bias | Largest | Smallest normal | Smallest subnormal | Epsilon | Digits |
|---|---|---|---|---|---|---|---|
| half (binary16) | 1 / 5 / 10 | 15 | 65504 | 6.104e−5 | 5.960e−8 | 9.766e−4 | 3 / 5 |
| bfloat16 | 1 / 8 / 7 | 127 | 3.390e38 | 1.175e−38 | 9.184e−41 | 7.813e−3 | 2 / 4 |
| float (binary32) | 1 / 8 / 23 | 127 | 3.403e38 | 1.175e−38 | 1.401e−45 | 1.192e−7 | 6 / 9 |
| double (binary64) | 1 / 11 / 52 | 1023 | 1.798e308 | 2.225e−308 | 4.941e−324 | 2.220e−16 | 15 / 17 |
"Digits" is digits10 / max_digits10: every decimal with the first count survives a round trip, and the second count is what you must print to get the same bits back. bfloat16 is the top half of a float. It keeps float's range but only about 2–3 significant digits, which is fine for neural-network weights and poor for sensor readings.
The encoder parses your decimal digits as an exact fraction and rounds once, to nearest with ties to even. It never rounds through a JavaScript double first, so 0.1, 65520 and other halfway cases come out the way a correct C compiler would store them. The tool shows the stored value's exact decimal expansion, the error against what you typed, and the ULP at that value.
Qm.n fixed point
The two naming conventions differ by one, so state the word size and n when you write a spec. Q15 0x4000 is 0.5 and 0x8000 is −1.0. +1.0 is not representable and saturates to 0x7FFF.
C struct layout
With natural alignment each member starts at a multiple of its own alignment, and the struct size rounds up to its largest member alignment. The gaps are padding, and their contents are whatever was on the stack. #pragma pack(n) caps every alignment at n, and __attribute__((packed)) removes padding entirely. The ABI matters: a double is 8-byte aligned on ARM (AAPCS) and x86-64 but only 4-byte aligned inside an i386 struct, and avr-gcc aligns everything to 1 byte.
Bit-field order is implementation-defined in C (C17 §6.7.2.1). This tool follows GCC and Clang on ARM and x86. A bit-field may not cross a naturally aligned unit of its declared type, so it moves to the next unit, unless the struct is packed. Little-endian targets fill from bit 0 of the lowest byte, and big-endian targets fill from the most significant bit. MSVC uses different rules. The layout was checked against arm-none-eabi-gcc output in both endiannesses. Copy the generated _Static_assert lines into your firmware so a compiler or flag change breaks the build instead of the protocol.
CRC parameters
"CRC-16-CCITT" names at least three different algorithms, so match by check value, not by name. The table recomputes each algorithm's check value live, which tests the implementation every time the page loads. If the last one, two or four bytes of the range are a CRC of the bytes before them, the tool says which algorithm and byte order match.
Pitfalls that cost firmware teams days
- Signed/unsigned mixing. In C,
-1 < 0uis false: the usual arithmetic conversions turn −1 into 0xFFFFFFFF before the compare. A loop counter compared againstsizeof, or a signed ADC delta stored in auint16_t, fails the same way. See the signed/unsigned firmware bug case study. - Sign extension.
int8_t0xFF widens to −1, which is 0xFFFFFFFF as a 32-bit pattern. Assembling a word asb[3] << 24 | …promotesuint8_tto signedint, so shifting 0x80 into bit 31 is undefined behavior. Cast touint32_tbefore the shift. - Endianness on the wire versus in memory. Network protocols are usually big-endian (RFC 1700 "network byte order"), and most MCUs are little-endian. Convert at the boundary with shifts or
htonl/ntohl. Never cast a byte pointer to auint32_t*: it can fault on an unaligned address, and it breaks strict aliasing. - Float compare.
0.1 + 0.2 == 0.3is false in double, because none of the three constants is exactly representable. NaN never equals anything, itself included, and −0 equals +0. Compare against a tolerance scaled to the values, or count ULPs between the bit patterns. Don't use float for a free-running timestamp: above 2^24 ms (4.7 hours) a float can no longer resolve 1 ms. - Half precision in sensor paths. binary16 tops out at 65504, and its ULP at 1000 is 0.5. A 16-bit fixed-point value usually carries the same data with better resolution.
Limits
- Engineering estimate and debugging aid, not a certified tool. Verify safety-relevant decoders against your compiler's own output.
- Struct decoding covers flat structs. Nested structs, unions,
long doubleand MSVC bit-field rules are not modelled, and AVR bit-field placement is approximate. Plaincharis shown signed. - CRCs use the bit-at-a-time Williams model for widths 1–32. Reflected custom polynomials are entered in normal (MSB-first) form, as in the RevEng catalogue.
- Inputs are capped only by your browser's memory. Very large pastes re-render on every keystroke.
References
- IEEE Std 754-2019, IEEE Standard for Floating-Point Arithmetic (binary16/32/64 interchange formats, roundTiesToEven).
- Intel, BFLOAT16 — Hardware Numerics Definition, document 338302, 2018.
- ISO/IEC 9899:2018 (C17): §6.3.1 conversions, §6.7.2.1 structure and bit-field layout.
- Arm, Procedure Call Standard for the Arm Architecture (AAPCS32, IHI 0042): data types, alignment, bit-fields. System V i386 and AMD64 psABI supplements.
- Arm CMSIS-DSP documentation:
q7_t/q15_t/q31_tfixed-point types and conversion functions. - G. Cook, Catalogue of parametrised CRC algorithms (RevEng), reveng.sourceforge.io/crc-catalogue. Check values used in this tool's tests.
- R. N. Williams, A Painless Guide to CRC Error Detection Algorithms, 1993 (the width/poly/init/refin/refout/xorout model).
- D. Goldberg, "What Every Computer Scientist Should Know About Floating-Point Arithmetic," ACM Computing Surveys 23(1), 1991.
- Modbus Organization, MODBUS over Serial Line Specification and Implementation Guide V1.02 (CRC-16 byte order).
- Scope references only, no code used: microsoft/vscode-hexeditor data inspector (MIT), WerWolv/ImHex pattern language, gregstoll floattohex.
Chasing a value that decodes to garbage?
Kyros does firmware and protocol bring-up for a living: wire formats, CRCs, fixed-point math, and the test fixtures that prove a board reports the numbers it should.
