This is a BINARY class.

It was deleveloped from an email posted on the 'BITS' CBUILDER mail group by James Mark Knox.

Email address email::techno.wizard@iname.com

This code is (C) James Mark Knox 1999 - But is free for use by all. There is NO warrenty with this code at all, Use at your own risk. Please download the zip file from here binary.zip. This file is included in the zip file, along with the BINARY.H file which contains the BINARY Class.

Constructors

BINARY(void)  
BINARY(const BINARY& b)  
BINARY(const char* str)  
BINARY(const char c) BINARY(const unsigned char c)
BINARY(const int c) BINARY(const unsigned int c)
BINARY(const short int c) BINARY(const unsigned short int c)
BINARY(const long int c) BINARY(const unsigned long int c)

 

Operator overloading

BINARY& operator = (const BINARY& b)

 

mathematical Operators

BINARY operator+ (const BINARY& b) BINARY& operator+= (const BINARY& b) Addition
BINARY operator- (const BINARY& b) BINARY& operator-= (const BINARY& b) Subtraction
BINARY operator* (const BINARY& b) BINARY& operator*= (const BINARY& b) Multiplication
BINARY operator/ (const BINARY& b) BINARY& operator/= (const BINARY& b) Division
BINARY operator% (const BINARY& b) BINARY& operator%= (const BINARY& b) Modulus

 

Comparisons

bool operator == (const BINARY& b) bool operator != (const BINARY& b) Equality and inequality
bool operator > (const BINARY& b) bool operator >= (const BINARY& b) Greater and greater or equal
bool operator < (const BINARY& b) bool operator <= (const BINARY& b) Less and Less or equal

 

Shift and Rotate

BINARY operator>>(const int shift) BINARY rotr(const int shift=1) Shift and rotate right
BINARY operator<<(const int shift) BINARY rotl(const int shift=1) Shift and rotate left

 

Bit Operations

BINARY Set_Bit(const int bit) BINARY Clear_Bit(const int bit) Set and Clear a bit
bool Bit(const int bit)   Test a bit

 

logical operations

BINARY operator &(const BINARY&b) BINARY operator &=(const BINARY&b) Logical AND
BINARY operator |(const BINARY&b) BINARY operator |=(const BINARY&b) Logical OR
BINARY operator ~()   Logical NOT
BINARY operator ^(const BINARY&b) BINARY operator ^=(const BINARY&b) Logical EXCLUSIVE OR

 

conversion operators

operator char*(void)  
operator char(void) operator unsigned char(void)
operator int(void) operator unsigned int(void)
operator short int(void) operator unsigned short int(void)
operator long int(void) operator unsigned long int(void)

 

stream output operator outputs a binary string to a stream

ostream& operator<< (ostream &os, BINARY &b)