SatCat5
satcat5::util::WideSigned< W > Struct Template Reference

Detailed Description

template<unsigned W>
struct satcat5::util::WideSigned< W >

Template for signed integers.

See also
wide_integer.h.

Definition at line 335 of file wide_integer.h.

#include <wide_integer.h>

Inheritance diagram for satcat5::util::WideSigned< W >:
[legend]
Collaboration diagram for satcat5::util::WideSigned< W >:
[legend]

Public Member Functions

bool is_negative () const
 Is this integer negative, i.e., x < 0?
 
satcat5::util::WideSigned< W > abs () const
 Absolute value.
 
void clamp (const WideSigned< W > &limit_pos)
 Clamp input to +/- limit_pos.
 
void divmod (const WideSigned< W > &rhs, WideSigned< W > &div, WideSigned< W > &mod) const
 Combined divide + modulo function.
 
WideSigned< W > div_round (const WideSigned< W > &rhs) const
 Divide and round toward zero.
 
unsigned width_bits () const
 Total width in bits.
 
unsigned width_words () const
 Total width in 32-bit words.
 
unsigned msb () const
 Index of most significant '1' bit.
 
constexpr u32 sign_extend () const
 Extend most significant word with either "0" or "FFFF...".
 
void log_to (satcat5::log::LogBuffer &obj) const
 Human-readable logging in hexadecimal format.
 
bool read_from (satcat5::io::Readable *rd)
 Read binary data from a given source.
 
void write_to (satcat5::io::Writeable *wr) const
 Write binary data from a given sink.
 
constexpr WideSigned ()
 Constructors for various input formats.
 
constexpr WideSigned (u32 rhs)
 Constructors for various input formats.
 
constexpr WideSigned (u64 rhs)
 Constructors for various input formats.
 
constexpr WideSigned (u32 hi, u32 lo)
 Constructors for various input formats.
 
 WideSigned (s32 rhs)
 Constructors for various input formats.
 
 WideSigned (s64 rhs)
 Constructors for various input formats.
 
 WideSigned (const satcat5::util::WideInteger< W > &rhs)
 Constructors for various input formats.
 
WideSigned< W > & operator= (const WideInteger< W > &rhs)
 Constructors for various input formats.
 
WideSigned< W > operator- () const
 Common arithmetic operators. More...
 
WideSigned< W > operator+ (const WideInteger< W > &rhs) const
 Common arithmetic operators. More...
 
WideSigned< W > & operator+= (const WideInteger< W > &rhs)
 Common arithmetic operators. More...
 
WideSigned< W > operator- (const WideInteger< W > &rhs) const
 Common arithmetic operators. More...
 
WideSigned< W > & operator-= (const WideInteger< W > &rhs)
 Common arithmetic operators. More...
 
WideSigned< W > operator* (const WideInteger< W > &rhs) const
 Common arithmetic operators. More...
 
WideSigned< W > & operator*= (const WideInteger< W > &rhs)
 Common arithmetic operators. More...
 
WideSigned< W > operator/ (const WideSigned< W > &rhs) const
 Common arithmetic operators. More...
 
WideSigned< W > operator% (const WideSigned< W > &rhs) const
 Common arithmetic operators. More...
 
WideSigned< W > & operator/= (const WideInteger< W > &rhs)
 Common arithmetic operators. More...
 
WideSigned< W > & operator%= (const WideInteger< W > &rhs)
 Common arithmetic operators. More...
 
WideSigned< W > operator<< (unsigned rhs) const
 Common arithmetic operators. More...
 
WideSigned< W > operator<<= (unsigned rhs)
 Common arithmetic operators. More...
 
WideSigned< W > operator>> (unsigned rhs) const
 Common arithmetic operators. More...
 
WideSigned< W > operator>>= (unsigned rhs)
 Common arithmetic operators. More...
 
WideSigned< W > operator~ () const
 Common arithmetic operators. More...
 
WideSigned< W > & operator|= (const WideInteger< W > &rhs)
 Common arithmetic operators. More...
 
WideSigned< W > & operator&= (const WideInteger< W > &rhs)
 Common arithmetic operators. More...
 
WideSigned< W > & operator^= (const WideInteger< W > &rhs)
 Common arithmetic operators. More...
 
WideSigned< W > operator| (const WideInteger< W > &rhs) const
 Common arithmetic operators. More...
 
WideSigned< W > operator& (const WideInteger< W > &rhs) const
 Common arithmetic operators. More...
 
WideSigned< W > operator^ (const WideInteger< W > &rhs) const
 Common arithmetic operators. More...
 
bool operator< (const WideSigned< W > &rhs) const
 Comparison operators.
 
bool operator> (const WideSigned< W > &rhs) const
 Comparison operators.
 
bool operator<= (const WideSigned< W > &rhs) const
 Comparison operators.
 
bool operator>= (const WideSigned< W > &rhs) const
 Comparison operators.
 
WideInteger< W > & operator++ ()
 Increment/decrement.
 
WideInteger< W > operator++ (int)
 Increment/decrement.
 
WideInteger< W > & operator-- ()
 Increment/decrement.
 
WideInteger< W > operator-- (int)
 Increment/decrement.
 
bool operator== (const WideInteger< W > &rhs) const
 Equality comparison only. More...
 
bool operator!= (const WideInteger< W > &rhs) const
 Equality comparison only. More...
 
 operator bool () const
 Conversion to other basic types.
 
constexpr operator int32_t () const
 Conversion to other basic types.
 
constexpr operator int64_t () const
 Conversion to other basic types.
 
constexpr operator uint32_t () const
 Conversion to other basic types.
 
constexpr operator uint64_t () const
 Conversion to other basic types.
 

Public Attributes

u32 m_data [W]
 Underlying data vector, LSW-first.
 

Protected Member Functions

template<unsigned W2>
void copy_from (const satcat5::util::WideInteger< W2 > &rhs, u32 ext)
 
WideInteger< W > add (const WideInteger< W > &rhs) const
 
void add_in_place (const WideInteger< W > &rhs)
 
WideInteger< W > subtract (const WideInteger< W > &rhs) const
 
WideInteger< W > multiply (const WideInteger< W > &rhs) const
 
WideInteger< W > shift_left (unsigned rhs) const
 
WideInteger< W > shift_right (unsigned rhs, u32 ext) const
 
WideInteger< W > bitwise_invert () const
 
void bitwise_or (const WideInteger< W > &rhs)
 
void bitwise_and (const WideInteger< W > &rhs)
 
void bitwise_xor (const WideInteger< W > &rhs)
 

Static Protected Member Functions

template<typename T >
static constexpr u32 sign_extend (T x)
 

Member Function Documentation

◆ operator!=()

template<unsigned W>
bool satcat5::util::WideInteger< W >::operator!= ( const WideInteger< W > &  rhs) const
inlineinherited

Equality comparison only.

Greater-than and less-than require signed/unsigned specialization.

Definition at line 104 of file wide_integer.h.

◆ operator%()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator% ( const WideSigned< W > &  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 395 of file wide_integer.h.

◆ operator%=()

template<unsigned W>
WideSigned<W>& satcat5::util::WideSigned< W >::operator%= ( const WideInteger< W > &  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 399 of file wide_integer.h.

◆ operator&()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator& ( const WideInteger< W > &  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 419 of file wide_integer.h.

◆ operator&=()

template<unsigned W>
WideSigned<W>& satcat5::util::WideSigned< W >::operator&= ( const WideInteger< W > &  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 413 of file wide_integer.h.

◆ operator*()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator* ( const WideInteger< W > &  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 389 of file wide_integer.h.

◆ operator*=()

template<unsigned W>
WideSigned<W>& satcat5::util::WideSigned< W >::operator*= ( const WideInteger< W > &  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 391 of file wide_integer.h.

◆ operator+()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator+ ( const WideInteger< W > &  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 381 of file wide_integer.h.

◆ operator+=()

template<unsigned W>
WideSigned<W>& satcat5::util::WideSigned< W >::operator+= ( const WideInteger< W > &  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 383 of file wide_integer.h.

◆ operator-() [1/2]

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator- ( ) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 379 of file wide_integer.h.

◆ operator-() [2/2]

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator- ( const WideInteger< W > &  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 385 of file wide_integer.h.

◆ operator-=()

template<unsigned W>
WideSigned<W>& satcat5::util::WideSigned< W >::operator-= ( const WideInteger< W > &  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 387 of file wide_integer.h.

◆ operator/()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator/ ( const WideSigned< W > &  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 393 of file wide_integer.h.

◆ operator/=()

template<unsigned W>
WideSigned<W>& satcat5::util::WideSigned< W >::operator/= ( const WideInteger< W > &  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 397 of file wide_integer.h.

◆ operator<<()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator<< ( unsigned  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 399 of file wide_integer.h.

◆ operator<<=()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator<<= ( unsigned  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 399 of file wide_integer.h.

◆ operator==()

template<unsigned W>
bool satcat5::util::WideInteger< W >::operator== ( const WideInteger< W > &  rhs) const
inlineinherited

Equality comparison only.

Greater-than and less-than require signed/unsigned specialization.

Definition at line 96 of file wide_integer.h.

◆ operator>>()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator>> ( unsigned  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 405 of file wide_integer.h.

◆ operator>>=()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator>>= ( unsigned  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 407 of file wide_integer.h.

◆ operator^()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator^ ( const WideInteger< W > &  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 421 of file wide_integer.h.

◆ operator^=()

template<unsigned W>
WideSigned<W>& satcat5::util::WideSigned< W >::operator^= ( const WideInteger< W > &  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 415 of file wide_integer.h.

◆ operator|()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator| ( const WideInteger< W > &  rhs) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 417 of file wide_integer.h.

◆ operator|=()

template<unsigned W>
WideSigned<W>& satcat5::util::WideSigned< W >::operator|= ( const WideInteger< W > &  rhs)
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 411 of file wide_integer.h.

◆ operator~()

template<unsigned W>
WideSigned<W> satcat5::util::WideSigned< W >::operator~ ( ) const
inline

Common arithmetic operators.

Returned type always matches the first argument.

Definition at line 409 of file wide_integer.h.


The documentation for this struct was generated from the following files: