68 L1GctTwosComplement
operator+(
const L1GctTwosComplement& rhs)
const;
74 L1GctTwosComplement&
operator=(
int value);
95 std::ostream& operator<<(std::ostream& s, const L1GctTwosComplement<nBits>&
data);
133 m_data =
static_cast<uint32_t
>(0);
146 int chkValue, posValue;
161 posValue = chkValue < 0 ? chkValue + (1 <<
MAX_NBITS) : chkValue;
162 raw =
static_cast<uint32_t
>(posValue);
173 maxValueInNbits = 1 << (
m_nBits - 1);
174 value =
static_cast<int>(
m_data);
175 result = value < maxValueInNbits ? value : value - (1 <<
MAX_NBITS);
188 sum = this->
raw() + rhs.
raw();
218 uint32_t signBit = 1 << (
m_nBits - 1);
219 uint32_t signExtendBits = (
static_cast<uint32_t
>(
MAX_VALUE) - signBit) << 1;
221 uint32_t mskRawValue = rawValue & ((1 <<
MAX_NBITS) - 1);
225 if ((mskRawValue & signBit) == 0) {
226 value = mskRawValue & ~signExtendBits;
228 value = mskRawValue | signExtendBits;
230 ofl = value != mskRawValue;
238 std::ostream& operator<<(std::ostream& s, const L1GctTwosComplement<nBits>&
data) {
239 s <<
"L1GctTwosComplement<" <<
data.size() <<
"> raw : " <<
data.raw() <<
", " 240 <<
"value : " <<
data.value();
241 if (
data.overFlow()) {
242 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