math::Binary Class Reference

Binary Number Object Copyright David Coss 2010 Copying and distributing are permitted under the terms of the GNU Public License version 3 (see COPYING or http://www.gnu.org/licenses/gpl.txt). More...

#include <Binary.h>


Public Member Functions

 Binary ()
 Default Constructor.
 Binary (const Binary &)
 Copy constructory.
 Binary (int)
 Creates binary number based on a positive integer.
 Binary (const DString &)
 Creates a binary number from a DString.
 ~Binary ()
Binary operator= (const Binary &B)
Binary operator+ (const Binary &B)
Binary operator- (const Binary &B)
bool operator== (const Binary &B)
Binary operator~ ()
 Returns the complement of the binary number.
Binary operator^ (const Binary &B)
 Returns the "exclusive or" of the the binary number.
Binary operator& (const Binary &B)
 Returns the "and" of the binary number.
Binary operator| (const Binary &B)
 Returns the "or" of the binary number.
Binary operator! ()
 Returns the compliment using operator~().
Binary nand (const Binary &B)
 Performs a "Not And" with the provided binary number.
Binary nor (const Binary &B)
 Performs a "Not Or" with the provided binary number.
int getInt () const
 Gives the *positive) integer value of the binary number.
DString toDString () const
int mostSigBit ()
int setBitSize (int newSize)
int getBitSize () const

Static Public Member Functions

static Binary toBinary (int)

Private Attributes

int * i
DStringbString
int bitSize


Detailed Description

Binary Number Object Copyright David Coss 2010 Copying and distributing are permitted under the terms of the GNU Public License version 3 (see COPYING or http://www.gnu.org/licenses/gpl.txt).

Constructor & Destructor Documentation

math::Binary::Binary (  ) 

Default Constructor.

Value equals zero.

References bitSize, bString, and i.

Referenced by nand(), and nor().

math::Binary::Binary ( const Binary B  ) 

Copy constructory.

References bitSize, bString, getBitSize(), getInt(), i, and toDString().

math::Binary::Binary ( int  newI  ) 

Creates binary number based on a positive integer.

This cannot handle negative numbers, for which a DavidException is thrown.

References bitSize, bString, i, DString::length(), toBinary(), and toDString().

math::Binary::Binary ( const DString bean  ) 

Creates a binary number from a DString.

If the string contains any character other than a "1" or "0", a DavidException is thrown.

References bitSize, bString, Double::exponent(), DavidException::FORMAT_ERROR_CODE, i, and DString::length().

math::Binary::~Binary (  ) 

References bString, and i.


Member Function Documentation

int math::Binary::getBitSize (  )  const [inline]

int math::Binary::getInt (  )  const [inline]

Gives the *positive) integer value of the binary number.

References i.

Referenced by Binary(), nor(), operator&(), operator+(), operator=(), operator^(), and operator|().

int math::Binary::mostSigBit (  )  [inline]

References DString::length(), and toDString().

Binary math::Binary::nand ( const Binary B  ) 

Performs a "Not And" with the provided binary number.

References Binary().

Binary math::Binary::nor ( const Binary B  ) 

Performs a "Not Or" with the provided binary number.

References Binary(), getInt(), and i.

Binary math::Binary::operator! (  )  [inline]

Returns the compliment using operator~().

Binary math::Binary::operator& ( const Binary B  ) 

Returns the "and" of the binary number.

References getBitSize(), getInt(), i, and setBitSize().

Binary math::Binary::operator+ ( const Binary B  ) 

References getBitSize(), getInt(), i, and setBitSize().

Binary math::Binary::operator- ( const Binary B  ) 

References bitSize, getBitSize(), i, and setBitSize().

Binary math::Binary::operator= ( const Binary B  ) 

bool math::Binary::operator== ( const Binary B  ) 

References bString, and i.

Binary math::Binary::operator^ ( const Binary B  ) 

Returns the "exclusive or" of the the binary number.

References bitSize, getBitSize(), getInt(), i, and setBitSize().

Binary math::Binary::operator| ( const Binary B  ) 

Returns the "or" of the binary number.

References getBitSize(), getInt(), i, and setBitSize().

Binary math::Binary::operator~ (  ) 

Returns the complement of the binary number.

References bitSize, bString, DString::charAt(), Double::exponent(), i, DString::length(), and setBitSize().

int math::Binary::setBitSize ( int  newSize  )  [inline]

Binary math::Binary::toBinary ( int  i  )  [static]

DString math::Binary::toDString (  )  const

References bitSize, bString, and DString::length().

Referenced by Binary(), mostSigBit(), operator=(), and toBinary().


Field Documentation

int math::Binary::bitSize [private]

int* math::Binary::i [private]


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

Generated on Fri Jun 11 21:02:36 2010 for libdnstd by  doxygen 1.5.7.1