4 #include <boost/cstdint.hpp> 69 L1GctTwosComplement
operator+ (
const L1GctTwosComplement &rhs)
const;
75 L1GctTwosComplement&
operator= (
int value);
97 std::ostream& operator<<(std::ostream& s, const L1GctTwosComplement<nBits>&
data);
135 m_data =
static_cast<uint32_t
>(0);
148 int chkValue, posValue;
157 posValue = chkValue<0 ? chkValue + (1<<
MAX_NBITS) : chkValue ;
158 raw =
static_cast<uint32_t
>(posValue);
169 maxValueInNbits = 1<<(
m_nBits-1);
170 value =
static_cast<int>(
m_data);
171 result = value < maxValueInNbits ? value : value - (1<<
MAX_NBITS) ;
186 sum = this->
raw() + rhs.
raw();
220 uint32_t signBit = 1<<(
m_nBits-1);
221 uint32_t signExtendBits = (
static_cast<uint32_t
>(
MAX_VALUE)-signBit)<<1;
223 uint32_t mskRawValue = rawValue & ((1<<
MAX_NBITS)-1);
227 if ((mskRawValue&signBit)==0) {
228 value = mskRawValue & ~signExtendBits;
230 value = mskRawValue | signExtendBits;
232 ofl = value != mskRawValue;
241 std::ostream& operator<<(std::ostream& s, const L1GctTwosComplement<nBits>&
data) {
243 s <<
"L1GctTwosComplement<" <<
data.size() <<
"> raw : " <<
data.raw() <<
", " <<
"value : " <<
data.value();
244 if (
data.overFlow()) {
s <<
" Overflow set! "; }
bool overFlow() const
access overflow
void setOverFlow(bool oflow)
set the overflow bit
void setRaw(uint32_t raw)
set the raw data
uint32_t raw() const
access raw data
~L1GctTwosComplement()
Destructor.
Definition of signed integer types with overflow.
static const int MAX_VALUE
void setValue(int value)
set value from signed int
void checkOverFlow(uint32_t rawValue, uint32_t &maskValue, bool &overFlow)
L1GctTwosComplement()
Construct a signed integer with initial value zero.
int value() const
access value as signed int
L1GctTwosComplement operator-() const
overload unary - (negation) operator
int size() const
return number of bits
char data[epos_bytes_allocation]
void reset()
reset value and overflow to zero
L1GctTwosComplement operator+(const L1GctTwosComplement &rhs) const
add two numbers of the same size
static const int MAX_NBITS
L1GctTwosComplement & operator=(int value)
overload = operator