2026-09-06 · 6 min read · Rahul Chitturi
- binary
- integers
- debugging
The hexadecimal value FF can mean 255 as an unsigned byte or -1 as an eight-bit two's complement integer. Without a declared width and signedness, converting digits between bases cannot determine the intended value.
These bugs appear in device registers, network fields, database drivers, binary files, and APIs that lose type metadata when values become JSON numbers or strings.
Record width before converting
Write down bit width, signedness, byte order, source bytes, destination type, and overflow behavior. In two's complement, the highest bit has sign significance only within that fixed width.
- Preserve leading zeroes that communicate field width
- Distinguish numeric conversion from byte-order reversal
- Apply sign extension only when widening a signed value
- Reject out-of-range values instead of wrapping accidentally
Trace representation boundaries
Inspect raw bytes before libraries coerce them into platform integers. Confirm whether protocol documentation writes multi-byte examples in network order, host order, or as a human-readable numeric hex value.
For JSON, define whether large or width-sensitive values travel as bounded numbers, decimal strings, or hexadecimal strings. Include the unit and signed interpretation in the schema or field name.
A Flashman workflow
Use the number base converter for unsigned digit checks, units converter for width and size context, hash to label public byte fixtures, diff to compare padded forms, and JSON formatter for transport examples.
Test zero, maximum positive, minimum negative, -1, sign-bit boundaries, widening and narrowing, both byte orders, malformed lengths, and every language binding that reads the field.