33 #include <itpp/itexports.h> 65 "bin::bin(): value must be 0 or 1");
74 "bin::operator=(): value must be 0 or 1");
75 b =
static_cast<char>(
value);
141 operator short()
const {
return static_cast<short>(b); }
143 operator int()
const {
return static_cast<int>(b); }
145 operator bool()
const {
return b != 0; }
147 operator float()
const {
return static_cast<float>(b); }
149 operator double()
const {
return static_cast<double>(b); }
162 ITPP_EXPORT std::ostream &
operator<<(std::ostream &output,
const bin &inbin);
168 ITPP_EXPORT std::istream &
operator>>(std::istream &input, bin &outbin);
186 inline int abs(
const itpp::bin &inbin) {
return inbin; }
190 #endif // #ifndef BINARY_H bin operator!(void) const
NOT.
void operator &=(const bin &inbin)
AND.
bin(const bin &inbin)
Copy constructor.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
bin operator*(const bin &inbin) const
AND.
bool operator!=(const int &i) const
Check if not equal.
bool operator<(const bin &inbin) const
Less than (interpret the binary values {0,1} as integers)
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
void operator^=(const bin &inbin)
XOR.
void operator|=(const bin &inbin)
OR.
void operator=(const int &value)
Assign a value.
void operator+=(const bin &inbin)
XOR.
bool operator==(const int &i) const
Check if equal.
bin operator-(const bin &inbin) const
XOR.
void operator-=(const bin &inbin)
XOR.
bool operator<=(const bin &inbin) const
Less than equal (interpret the binary values {0,1} as integers)
bin operator-() const
Dummy definition to be able to use vec<bin>
void operator/=(const bin &inbin)
OR.
bin operator &(const bin &inbin) const
AND.
bool operator!=(const bin &inbin) const
Check if not equal.
Error handling functions - header file.
bool operator==(const bin &inbin) const
Check if equal.
void operator=(const bin &inbin)
Assign a value.
bin()
Default constructor.
bin(const int &value)
Set the binary object equal to value. Either "0" or "1".
char value() const
Output the binary value of the object.
bin operator~(void) const
NOT.
void operator*=(const bin &inbin)
AND.
bin operator+(const bin &inbin) const
XOR.
bool operator>=(const bin &inbin) const
Greater than equal (interpret the binary values {0,1} as integers)
Binary arithmetic (boolean) class.
bin operator|(const bin &inbin) const
OR.
bin abs(const bin &inbin)
absolute value of bin
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
bool operator>(const bin &inbin) const
Greater than (interpret the binary values {0,1} as integers)
bin operator/(const bin &inbin) const
OR.
bin operator^(const bin &inbin) const
XOR.