itpp::bin Class Reference

Binary arithmetic (boolean) class. More...

`#include <itpp/base/binary.h>`

## Public Member Functions

| bin ()
| Default constructor.
| bin (const int &value)
| Set the binary object equal to `value`. Either "0" or "1".
| bin (const bin &inbin)
| Copy constructor.
void | operator= (const int &value)
| Assign a value.
void | operator= (const bin &inbin)
| Assign a value.
void | operator/= (const bin &inbin)
| OR.
void | operator|= (const bin &inbin)
| OR.
bin | operator/ (const bin &inbin) const
| OR.
bin | operator| (const bin &inbin) const
| OR.
void | operator+= (const bin &inbin)
| XOR.
void | operator^= (const bin &inbin)
| XOR.
bin | operator+ (const bin &inbin) const
| XOR.
bin | operator^ (const bin &inbin) const
| XOR.
void | operator-= (const bin &inbin)
| XOR.
bin | operator- (const bin &inbin) const
| XOR.
bin | operator- () const
| Dummy definition to be able to use vec<bin>
void | operator*= (const bin &inbin)
| AND.
void | operator&= (const bin &inbin)
| AND.
bin | operator* (const bin &inbin) const
| AND.
bin | operator& (const bin &inbin) const
| AND.
bin | operator! (void) const
| NOT.
bin | operator~ (void) const
| NOT.
bool | operator== (const bin &inbin) const
| Check if equal.
bool | operator== (const int &i) const
| Check if equal.
bool | operator!= (const bin &inbin) const
| Check if not equal.
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)
bool | operator<= (const bin &inbin) const
| Less than equal (interpret the binary values {0,1} as integers)
bool | operator> (const bin &inbin) const
| Greater than (interpret the binary values {0,1} as integers)
bool | operator>= (const bin &inbin) const
| Greater than equal (interpret the binary values {0,1} as integers)
| operator short () const
| Convert `bin` to `short`.
| operator int () const
| Convert `bin` to `int`.
| operator bool () const
| Convert `bin` to `bool`.
| operator float () const
| Convert `bin` to `float`.
| operator double () const
| Convert `bin` to `double`.
char | value () const
| Output the binary value of the object.

## Related Symbols

(Note that these are not member symbols.)
ITPP_EXPORT std::ostream & | operator<< (std::ostream &output, const bin &inbin)
| Output stream of bin.
ITPP_EXPORT std::istream & | operator>> (std::istream &input, bin &outbin)
| Input stream of bin.
bin | abs (const bin &inbin)
| absolute value of bin

## Detailed Description

Binary arithmetic (boolean) class.

Author
  Tony Ottosson

This class creates a binary arithmetic class, following the ordinary rules for binary (GF(2)) fields.

Examples:

bin a; // Creation of variable
bin a = 0; // Creating a variable and assigning it value 0
bin b = 1; // Creating a variable and assigning it value 1
bin c = a + b; // XOR operation
c = !a; // NOT
c = a * b; // AND
c = a / b; // OR
itpp::Array
General array class.
Definition array.h:105
itpp::bin
Binary arithmetic (boolean) class.
Definition binary.h:57

Definition at line 56 of file binary.h.

## Constructor & Destructor Documentation

## bin() [1/3]

itpp::bin::bin | ( |  | ) |

inline

Default constructor.

Definition at line 60 of file binary.h.

Referenced by operator!(), operator&(), operator*(), operator+(), operator-(), operator-(), operator/(), operator^(), operator|(), and operator~().

## bin() [2/3]

itpp::bin::bin | ( | const int & | value | ) |

inline

Set the binary object equal to `value`. Either "0" or "1".

Definition at line 63 of file binary.h.

References it_assert_debug, and value().

## bin() [3/3]

itpp::bin::bin | ( | const bin & | inbin | ) |

inline

Copy constructor.

Definition at line 69 of file binary.h.

## Member Function Documentation

## operator=() [1/2]

void itpp::bin::operator= | ( | const int & | value | ) |

inline

Assign a value.

Definition at line 72 of file binary.h.

References it_assert_debug, and value().

## operator=() [2/2]

void itpp::bin::operator= | ( | const bin & | inbin | ) |

inline

Assign a value.

Definition at line 79 of file binary.h.

## operator/=()

void itpp::bin::operator/= | ( | const bin & | inbin | ) |

inline

OR.

Definition at line 82 of file binary.h.

## operator|=()

void itpp::bin::operator|= | ( | const bin & | inbin | ) |

inline

OR.

Definition at line 85 of file binary.h.

## operator/()

bin itpp::bin::operator/ | ( | const bin & | inbin | ) | const

inline

OR.

Definition at line 87 of file binary.h.

References bin().

## operator|()

bin itpp::bin::operator| | ( | const bin & | inbin | ) | const

inline

OR.

Definition at line 89 of file binary.h.

References bin().

## operator+=()

void itpp::bin::operator+= | ( | const bin & | inbin | ) |

inline

XOR.

Definition at line 92 of file binary.h.

## operator^=()

void itpp::bin::operator^= | ( | const bin & | inbin | ) |

inline

XOR.

Definition at line 94 of file binary.h.

## operator+()

bin itpp::bin::operator+ | ( | const bin & | inbin | ) | const

inline

XOR.

Definition at line 96 of file binary.h.

References bin().

## operator^()

bin itpp::bin::operator^ | ( | const bin & | inbin | ) | const

inline

XOR.

Definition at line 98 of file binary.h.

References bin().

## operator-=()

void itpp::bin::operator-= | ( | const bin & | inbin | ) |

inline

XOR.

Definition at line 100 of file binary.h.

## operator-() [1/2]

bin itpp::bin::operator- | ( | const bin & | inbin | ) | const

inline

XOR.

Definition at line 102 of file binary.h.

References bin().

## operator-() [2/2]

bin itpp::bin::operator- | ( |  | ) | const

inline

Dummy definition to be able to use vec<bin>

Definition at line 104 of file binary.h.

References bin().

## operator*=()

void itpp::bin::operator*= | ( | const bin & | inbin | ) |

inline

AND.

Definition at line 107 of file binary.h.

## operator&=()

void itpp::bin::operator&= | ( | const bin & | inbin | ) |

inline

AND.

Definition at line 109 of file binary.h.

## operator*()

bin itpp::bin::operator* | ( | const bin & | inbin | ) | const

inline

AND.

Definition at line 111 of file binary.h.

References bin().

## operator&()

bin itpp::bin::operator& | ( | const bin & | inbin | ) | const

inline

AND.

Definition at line 113 of file binary.h.

References bin().

## operator!()

bin itpp::bin::operator! | ( | void |  | ) | const

inline

NOT.

Definition at line 116 of file binary.h.

References bin().

## operator~()

bin itpp::bin::operator~ | ( | void |  | ) | const

inline

NOT.

Definition at line 118 of file binary.h.

References bin().

## operator==() [1/2]

bool itpp::bin::operator== | ( | const bin & | inbin | ) | const

inline

Check if equal.

Definition at line 121 of file binary.h.

## operator==() [2/2]

bool itpp::bin::operator== | ( | const int & | i | ) | const

inline

Check if equal.

Definition at line 123 of file binary.h.

## operator!=() [1/2]

bool itpp::bin::operator!= | ( | const bin & | inbin | ) | const

inline

Check if not equal.

Definition at line 126 of file binary.h.

## operator!=() [2/2]

bool itpp::bin::operator!= | ( | const int & | i | ) | const

inline

Check if not equal.

Definition at line 128 of file binary.h.

## operator<()

bool itpp::bin::operator< | ( | const bin & | inbin | ) | const

inline

Less than (interpret the binary values {0,1} as integers)

Definition at line 131 of file binary.h.

## operator<=()

bool itpp::bin::operator<= | ( | const bin & | inbin | ) | const

inline

Less than equal (interpret the binary values {0,1} as integers)

Definition at line 133 of file binary.h.

## operator>()

bool itpp::bin::operator> | ( | const bin & | inbin | ) | const

inline

Greater than (interpret the binary values {0,1} as integers)

Definition at line 136 of file binary.h.

## operator>=()

bool itpp::bin::operator>= | ( | const bin & | inbin | ) | const

inline

Greater than equal (interpret the binary values {0,1} as integers)

Definition at line 138 of file binary.h.

## operator short()

itpp::bin::operator short | ( |  | ) | const

inline

Convert `bin` to `short`.

Definition at line 141 of file binary.h.

## operator int()

itpp::bin::operator int | ( |  | ) | const

inline

Convert `bin` to `int`.

Definition at line 143 of file binary.h.

## operator bool()

itpp::bin::operator bool | ( |  | ) | const

inline

Convert `bin` to `bool`.

Definition at line 145 of file binary.h.

## operator float()

itpp::bin::operator float | ( |  | ) | const

inline

Convert `bin` to `float`.

Definition at line 147 of file binary.h.

## operator double()

itpp::bin::operator double | ( |  | ) | const

inline

Convert `bin` to `double`.

Definition at line 149 of file binary.h.

## value()

char itpp::bin::value | ( |  | ) | const

inline

Output the binary value of the object.

Definition at line 152 of file binary.h.

Referenced by bin(), itpp::it_file::low_level_write(), itpp::it_file_old::low_level_write(), and operator=().

## Friends And Related Symbol Documentation

## operator<<()

ITPP_EXPORT std::ostream & operator<< | ( | std::ostream & | output,
|  | const bin & | inbin
| ) |  |

related

Output stream of bin.

Definition at line 36 of file binary.cpp.

## operator>>()

ITPP_EXPORT std::istream & operator>> | ( | std::istream & | input,
|  | bin & | outbin
| ) |  |

related

Input stream of bin.

Definition at line 42 of file binary.cpp.

References it_assert.

## abs()

bin abs | ( | const bin & | inbin | ) |

related

absolute value of bin

Definition at line 174 of file binary.h.

The documentation for this class was generated from the following file:

- itpp/base/binary.h

Generated on Mon Jun 10 2024 11:49:33 for IT++ by Doxygen 1.9.8