pub trait SignedNumeric: Numeric {
    // Required methods
    fn is_negative(self) -> bool;
    fn as_negative(self, bits: u32) -> Self;
    fn as_unsigned(self, bits: u32) -> Self;
    fn signed_value(self) -> SignedValue;
}
Expand description

This trait extends many common signed integer types so that they can be used with the bitstream handling traits.

Required Methods§

source

fn is_negative(self) -> bool

Returns true if this value is negative

source

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.

source

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.

source

fn signed_value(self) -> SignedValue

Converts to a generic signed value for stream recording purposes.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl SignedNumeric for i8

source§

fn is_negative(self) -> bool

source§

fn as_negative(self, bits: u32) -> Self

source§

fn as_unsigned(self, bits: u32) -> Self

source§

fn signed_value(self) -> SignedValue

source§

impl SignedNumeric for i16

source§

fn is_negative(self) -> bool

source§

fn as_negative(self, bits: u32) -> Self

source§

fn as_unsigned(self, bits: u32) -> Self

source§

fn signed_value(self) -> SignedValue

source§

impl SignedNumeric for i32

source§

fn is_negative(self) -> bool

source§

fn as_negative(self, bits: u32) -> Self

source§

fn as_unsigned(self, bits: u32) -> Self

source§

fn signed_value(self) -> SignedValue

source§

impl SignedNumeric for i64

source§

fn is_negative(self) -> bool

source§

fn as_negative(self, bits: u32) -> Self

source§

fn as_unsigned(self, bits: u32) -> Self

source§

fn signed_value(self) -> SignedValue

source§

impl SignedNumeric for i128

source§

fn is_negative(self) -> bool

source§

fn as_negative(self, bits: u32) -> Self

source§

fn as_unsigned(self, bits: u32) -> Self

source§

fn signed_value(self) -> SignedValue

Implementors§