pub fn decode_binary_int_fast(
data: &[u8],
bits: u16,
signed: bool,
) -> Result<i64>Expand description
Decode a COBOL binary integer (USAGE BINARY / COMP) with optimized fast paths for 16-, 32-, and 64-bit widths.
For the three common widths this function reads the big-endian bytes
directly into the native integer type, avoiding the generic loop in
decode_binary_int. Uncommon widths fall back to that generic
implementation.
§Arguments
data- Raw big-endian byte data containing the binary integerbits- Expected field width in bits (16, 32, or 64 for fast path)signed- Whether the field is signed (PIC S9 COMP) or unsigned (PIC 9 COMP)
§Returns
The decoded integer value as i64.
§Errors
CBKD401_COMP3_INVALID_NIBBLE- if an unsigned 64-bit value exceedsi64::MAX- Delegates to
decode_binary_intfor unsupported widths, which may return its own errors.
§See Also
decode_binary_int- General-purpose binary integer decoderencode_binary_int- Binary integer encoderformat_binary_int_to_string_with_scratch- Formats the decoded value to a string