/// Use an i128 to calculate the twos complement of Decimals with a precision up to and including 38
Use an i128 to calculate the twos complement of Decimals with a precision up to and including 38
Use an i128 to calculate the twos complement of Decimals with a precision up to and including 38
fn twos_complement_i128(
        decimal: &CStr,
        length: usize,
        digits: &mut Vec<u8>,
    ) -> FixedLenByteArray {
        use atoi::FromRadix10Signed;
        digits.clear();
        digits.extend(decimal.to_bytes().iter().filter(|&&c| c != b'.'));
        let (num, _consumed) = i128::from_radix_10_signed(&digits);
        let out = num.to_be_bytes()[(16 - length)..].to_owned();
        // Vec<u8> -> ByteArray -> FixedLenByteArray
        let out: ByteArray = out.into();
        out.into()
    }
fn twos_complement_i128 ( decimal : & CStr , length : usize , digits : & mut Vec < u8 > , ) -> FixedLenByteArray { use atoi :: FromRadix10Signed ; digits . clear ( ) ; digits . extend ( decimal . to_bytes ( ) . iter ( ) . filter ( | & & c | c != b'.' ) ) ; let ( num , _consumed ) = i128 :: from_radix_10_signed ( & digits ) ; let out = num . to_be_bytes ( ) [ ( 16 - length ) .. ] . to_owned ( ) ; // Vec<u8> -> ByteArray -> FixedLenByteArray let out : ByteArray = out . into ( ) ; out . into ( ) }
Use an i128 to calculate the twos complement of Decimals with a precision up to and including 38
Use an i128 to calculate the twos complement of Decimals with a precision up to and including 38
decimal
&CStr
length
usize
digits
&mut Vec<u8>