Kyros Engineering Engineering Tools
Home › Tools › Data Format Inspector
// Firmware tools Proto v0.1EndiannessIEEE-754Qm.nC structsCRC

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.

Runs entirely in your browser. Nothing is uploaded.

1 · Bytes

—
byte

2 · Fixed point

bits
bits
—

Interpretation

Each type read from the offset in each byte order. Small text is the assembled word.

Bit view

Hover a bit for its index, field, weight and memory location. Click to flip it.

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

TypeStored valueLE bytesBE bytesNote

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.

byte

5 · CRC range

byte
bytes

Custom CRC

Struct fields

OffsetSizeFieldTypeRawValue

Lock the layout in firmware


      

CRC

—
AlgorithmParametersCRCOn the wireCheck "123456789"

6 · Base converter

bits

Conversions

// How it works

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.

unsigned U = Σ byte_i · 256^i (byte_0 = least significant) signed S = U − 2^N if the top bit is set (two's complement, N bits) LE memory D C B A → word ABCD BE memory A B C D → word ABCD CDAB memory C D A B → word ABCD BADC memory B A D C → word ABCD

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

normal value = (−1)^s · 1.m · 2^(E − bias) 1 ≤ E ≤ 2^e − 2 subnormal value = (−1)^s · 0.m · 2^(1 − bias) E = 0, m ≠ 0 special E all ones: m = 0 → ±∞, m ≠ 0 → NaN (quiet if the top mantissa bit is set) ULP 2^(max(E − bias, 1 − bias) − p + 1) p = mantissa bits + 1
FormatSign/exp/mantBiasLargestSmallest normalSmallest subnormalEpsilonDigits
half (binary16)1 / 5 / 1015655046.104e−55.960e−89.766e−43 / 5
bfloat161 / 8 / 71273.390e381.175e−389.184e−417.813e−32 / 4
float (binary32)1 / 8 / 231273.403e381.175e−381.401e−451.192e−76 / 9
double (binary64)1 / 11 / 5210231.798e3082.225e−3084.941e−3242.220e−1615 / 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

value = raw / 2^n raw = round(x · 2^n), saturated to the word range −2^m … 2^m − 2^−n (signed) resolution 2^−n ARM name Qm.n: m excludes the sign bit (Q15 = Q0.15) TI name: m includes it (Q15 = Q1.15)

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

width · poly · init · refin · refout · xorout check = CRC("123456789") CRC-16/IBM-3740 ("CCITT-FALSE") poly 0x1021 init 0xFFFF check 0x29B1 CRC-16/KERMIT (true CCITT) poly 0x1021 init 0x0000 reflected check 0x2189 CRC-16/MODBUS poly 0x8005 init 0xFFFF reflected check 0x4B37, sent low byte first

"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

Limits

References

  1. IEEE Std 754-2019, IEEE Standard for Floating-Point Arithmetic (binary16/32/64 interchange formats, roundTiesToEven).
  2. Intel, BFLOAT16 — Hardware Numerics Definition, document 338302, 2018.
  3. ISO/IEC 9899:2018 (C17): §6.3.1 conversions, §6.7.2.1 structure and bit-field layout.
  4. Arm, Procedure Call Standard for the Arm Architecture (AAPCS32, IHI 0042): data types, alignment, bit-fields. System V i386 and AMD64 psABI supplements.
  5. Arm CMSIS-DSP documentation: q7_t/q15_t/q31_t fixed-point types and conversion functions.
  6. G. Cook, Catalogue of parametrised CRC algorithms (RevEng), reveng.sourceforge.io/crc-catalogue. Check values used in this tool's tests.
  7. R. N. Williams, A Painless Guide to CRC Error Detection Algorithms, 1993 (the width/poly/init/refin/refout/xorout model).
  8. D. Goldberg, "What Every Computer Scientist Should Know About Floating-Point Arithmetic," ACM Computing Surveys 23(1), 1991.
  9. Modbus Organization, MODBUS over Serial Line Specification and Implementation Guide V1.02 (CRC-16 byte order).
  10. 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.

Talk about your project →