Trait bitstream_io::SignedNumeric
source · pub trait SignedNumeric: Numeric {
fn is_negative(self) -> bool;
fn as_negative(self, bits: u32) -> Self;
fn as_unsigned(self, bits: u32) -> Self;
}
Expand description
This trait extends many common signed integer types so that they can be used with the bitstream handling traits.
Required Methods
sourcefn is_negative(self) -> bool
fn is_negative(self) -> bool
Returns true if this value is negative
sourcefn as_negative(self, bits: u32) -> Self
fn as_negative(self, bits: u32) -> Self
Given a two-complement positive value and certain number of bits, returns this value as a negative number.
sourcefn as_unsigned(self, bits: u32) -> Self
fn as_unsigned(self, bits: u32) -> Self
Given a negative value and a certain number of bits, returns this value as a twos-complement positive number.