fn write_sign_extended<W: Write + ?Sized>(
out: &mut W,
src_be: &[u8],
n: usize,
) -> Result<(), ArrowError>
Expand description
Sign-extend (or validate/truncate) big-endian integer bytes to exactly n
bytes.
- If shorter than
n
, the slice is sign-extended by left-padding with the sign byte (0x00
for positive,0xFF
for negative). - If longer than
n
, the slice is truncated from the left. An overflow error is returned if any of the truncated bytes are not redundant sign bytes, or if the resulting value’s sign bit would differ from the original. - If the slice is already
n
bytes long, it is copied.
Used for encoding Avro decimal values into fixed(N)
fields.