pub fn numeric_to_twos_complement_be(
    mut numeric: Numeric,
) -> [u8; Numeric::TWOS_COMPLEMENT_BYTE_WIDTH] {
    let mut buf = [0; Numeric::TWOS_COMPLEMENT_BYTE_WIDTH];
    // Avro doesn't specify how to handle NaN/infinity, so we simply treat them
    // as zeroes so as to avoid erroring (encoding values is meant to be
    // infallible) and retain downstream associativity/commutativity.
    if numeric.is_special() {
        return buf;
    }

    let mut cx = Numeric::context();

    // Ensure `numeric` is a canonical coefficient.
    if numeric.exponent() < 0 {
        let s = Numeric::from(-numeric.exponent());
        cx.scaleb(&mut numeric, &s);
    }

    numeric_to_twos_complement_inner::<Numeric, NUMERIC_DATUM_WIDTH>(numeric, &mut cx, &mut buf);
    buf
}
/// Converts an [`Numeric`] into its big endian two's complement representation.
Converts an [`Numeric`] into its big endian two's complement representation.
Converts an [ ` Numeric ` ] into its big endian two ' s complement representation .
pub fn numeric_to_twos_complement_be(
    mut numeric: Numeric,
) -> [u8; Numeric::TWOS_COMPLEMENT_BYTE_WIDTH] {
    let mut buf = [0; Numeric::TWOS_COMPLEMENT_BYTE_WIDTH];
    // Avro doesn't specify how to handle NaN/infinity, so we simply treat them
    // as zeroes so as to avoid erroring (encoding values is meant to be
    // infallible) and retain downstream associativity/commutativity.
    if numeric.is_special() {
        return buf;
    }
    let mut cx = Numeric::context();
    // Ensure `numeric` is a canonical coefficient.
    if numeric.exponent() < 0 {
        let s = Numeric::from(-numeric.exponent());
        cx.scaleb(&mut numeric, &s);
    }
    numeric_to_twos_complement_inner::<Numeric, NUMERIC_DATUM_WIDTH>(numeric, &mut cx, &mut buf);
    buf
}
pub fn numeric_to_twos_complement_be ( mut numeric : Numeric , ) -> [ u8 ; Numeric :: TWOS_COMPLEMENT_BYTE_WIDTH ] { let mut buf = [ 0 ; Numeric :: TWOS_COMPLEMENT_BYTE_WIDTH ] ; // Avro doesn't specify how to handle NaN/infinity, so we simply treat them // as zeroes so as to avoid erroring (encoding values is meant to be // infallible) and retain downstream associativity/commutativity. if numeric . is_special ( ) { return buf ; } let mut cx = Numeric :: context ( ) ; // Ensure `numeric` is a canonical coefficient. if numeric . exponent ( ) < 0 { let s = Numeric :: from ( - numeric . exponent ( ) ) ; cx . scaleb ( & mut numeric , & s ) ; } numeric_to_twos_complement_inner :: < Numeric , NUMERIC_DATUM_WIDTH > ( numeric , & mut cx , & mut buf ) ; buf }
Converts an [`Numeric`] into its big endian two's complement representation.
Converts an [ ` Numeric ` ] into its big endian two ' s complement representation .
numeric
Numeric
numeric
Numeric