• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

qca

QCA::BigInteger

QCA::BigInteger Class Reference
[QCA user API]

#include <QtCrypto>

List of all members.


Detailed Description

Arbitrary precision integer.

BigInteger provides arbitrary precision integers.

if ( BigInteger("3499543804349") == 
    BigInteger("38493290803248") + BigInteger( 343 ) )
{
    // do something
}

Definition at line 570 of file qca_tools.h.


Public Member Functions

 BigInteger (const BigInteger &from)
 BigInteger (const QCA::SecureArray &a)
 BigInteger (const QString &s)
 BigInteger (const char *c)
 BigInteger (int n)
 BigInteger ()
int compare (const BigInteger &n) const
void fromArray (const QCA::SecureArray &a)
bool fromString (const QString &s)
BigInteger & operator *= (const BigInteger &b)
bool operator!= (const BigInteger &other) const
BigInteger & operator%= (const BigInteger &b)
BigInteger & operator+= (const BigInteger &b)
BigInteger & operator-= (const BigInteger &b)
BigInteger & operator/= (const BigInteger &b)
bool operator< (const BigInteger &other) const
bool operator<= (const BigInteger &other) const
BigInteger & operator= (const QString &s)
BigInteger & operator= (const BigInteger &from)
bool operator== (const BigInteger &other) const
bool operator> (const BigInteger &other) const
bool operator>= (const BigInteger &other) const
QCA::SecureArray toArray () const
QString toString () const
 ~BigInteger ()

Related Functions

(Note that these are not member functions.)

QCA_EXPORT QTextStream & operator<< (QTextStream &stream, const BigInteger &b)

Constructor & Destructor Documentation

QCA::BigInteger::BigInteger (  ) 

Constructor.

Creates a new BigInteger, initialised to zero.

Definition at line 785 of file qca_tools.cpp.

QCA::BigInteger::BigInteger ( int  n  ) 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
n an alternative integer initialisation value.

Definition at line 790 of file qca_tools.cpp.

QCA::BigInteger::BigInteger ( const char *  c  ) 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
c an alternative initialisation value, encoded as a character array
BigInteger b ( "9890343" );

Definition at line 805 of file qca_tools.cpp.

QCA::BigInteger::BigInteger ( const QString &  s  ) 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
s an alternative initialisation value, encoded as a string

Definition at line 811 of file qca_tools.cpp.

QCA::BigInteger::BigInteger ( const QCA::SecureArray &  a  ) 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
a an alternative initialisation value, encoded as SecureArray

Definition at line 817 of file qca_tools.cpp.

QCA::BigInteger::BigInteger ( const BigInteger &  from  ) 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
from an alternative initialisation value, encoded as a BigInteger

Definition at line 823 of file qca_tools.cpp.

QCA::BigInteger::~BigInteger (  ) 

Definition at line 828 of file qca_tools.cpp.


Member Function Documentation

int QCA::BigInteger::compare ( const BigInteger &  n  )  const

Compare this value with another BigInteger.

Normally it is more readable to use one of the operator overloads, so you don't need to use this method directly.

Parameters:
n the BigInteger to compare with
Returns:
zero if the values are the same, negative if the argument is less than the value of this BigInteger, and positive if the argument value is greater than this BigInteger
BigInteger a( "400" );
BigInteger b( "-400" );
BigInteger c( " 200 " );
int result;
result = a.compare( b );        // return positive 400 > -400
result = a.compare( c );        // return positive,  400 > 200
result = b.compare( c );        // return negative, -400 < 200

Definition at line 890 of file qca_tools.cpp.

void QCA::BigInteger::fromArray ( const QCA::SecureArray &  a  ) 

Assign from an array.

The input is expected to be a binary integer in sign-extended network-byte-order.

Parameters:
a a SecureArray that represents an integer
See also:
BigInteger(const SecureArray &a);

SecureArray toArray() const;

Definition at line 935 of file qca_tools.cpp.

bool QCA::BigInteger::fromString ( const QString &  s  ) 

Assign from a QString.

Parameters:
s a QString that represents an integer
Note:
it is the application's responsibility to make sure that the QString represents a valid integer (ie it only contains numbers and an optional minus sign at the start)
See also:
BigInteger(const QString &s)

BigInteger & operator=(const QString &s)

Definition at line 975 of file qca_tools.cpp.

BigInteger & QCA::BigInteger::operator *= ( const BigInteger &  b  ) 

Multiply in place operator.

Parameters:
b the amount to multiply by

Definition at line 850 of file qca_tools.cpp.

bool QCA::BigInteger::operator!= ( const BigInteger &  other  )  const [inline]

Inequality operator.

Returns true if the two BigInteger values are different in magnitude, sign or both.

Parameters:
other the BigInteger to compare to

Definition at line 780 of file qca_tools.h.

BigInteger & QCA::BigInteger::operator%= ( const BigInteger &  b  ) 

Modulo in place operator.

Parameters:
b the amount to divide by

Definition at line 870 of file qca_tools.cpp.

BigInteger & QCA::BigInteger::operator+= ( const BigInteger &  b  ) 

Increment in place operator.

Parameters:
b the amount to increment by
BigInteger a; // a is zero
BigInteger b( 500 );
a += b; // a is now 500
a += b; // a is now 1000

Definition at line 838 of file qca_tools.cpp.

BigInteger & QCA::BigInteger::operator-= ( const BigInteger &  b  ) 

Decrement in place operator.

Parameters:
b the amount to decrement by
BigInteger a; // a is zero
BigInteger b( 500 );
a -= b; // a is now -500
a -= b; // a is now -1000

Definition at line 844 of file qca_tools.cpp.

BigInteger & QCA::BigInteger::operator/= ( const BigInteger &  b  ) 

Divide in place operator.

Parameters:
b the amount to divide by

Definition at line 856 of file qca_tools.cpp.

bool QCA::BigInteger::operator< ( const BigInteger &  other  )  const [inline]

Less than operator.

Returns true if the BigInteger value on the left hand side is less than the BigInteger value on the right hand side.

Parameters:
other the BigInteger to compare to

Definition at line 816 of file qca_tools.h.

bool QCA::BigInteger::operator<= ( const BigInteger &  other  )  const [inline]

Less than or equal operator.

Returns true if the BigInteger value on the left hand side is equal to or less than the BigInteger value on the right hand side.

Parameters:
other the BigInteger to compare to

Definition at line 792 of file qca_tools.h.

BigInteger & QCA::BigInteger::operator= ( const QString &  s  ) 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
s the QString containing an integer representation
See also:
bool fromString(const QString &s)
Note:
it is the application's responsibility to make sure that the QString represents a valid integer (ie it only contains numbers and an optional minus sign at the start)

Definition at line 884 of file qca_tools.cpp.

BigInteger & QCA::BigInteger::operator= ( const BigInteger &  from  ) 

Assignment operator.

Parameters:
from the BigInteger to copy from
BigInteger a; // a is zero
BigInteger b( 500 );
a = b; // a is now 500

Definition at line 832 of file qca_tools.cpp.

bool QCA::BigInteger::operator== ( const BigInteger &  other  )  const [inline]

Equality operator.

Returns true if the two BigInteger values are the same, including having the same sign.

Parameters:
other the BigInteger to compare to

Definition at line 769 of file qca_tools.h.

bool QCA::BigInteger::operator> ( const BigInteger &  other  )  const [inline]

Greater than operator.

Returns true if the BigInteger value on the left hand side is greater than the BigInteger value on the right hand side.

Parameters:
other the BigInteger to compare to

Definition at line 828 of file qca_tools.h.

bool QCA::BigInteger::operator>= ( const BigInteger &  other  )  const [inline]

Greater than or equal operator.

Returns true if the BigInteger value on the left hand side is equal to or greater than the BigInteger value on the right hand side.

Parameters:
other the BigInteger to compare to

Definition at line 804 of file qca_tools.h.

SecureArray QCA::BigInteger::toArray (  )  const

Output BigInteger as a byte array, useful for storage or transmission.

The format is a binary integer in sign-extended network-byte-order.

See also:
void fromArray(const SecureArray &a);

Definition at line 901 of file qca_tools.cpp.

QString QCA::BigInteger::toString (  )  const

Convert BigInteger to a QString.

QString aString;
BigInteger aBiggishInteger( 5878990 );
aString = aBiggishInteger.toString(); // aString is now "5878990"

Definition at line 955 of file qca_tools.cpp.


Friends And Related Function Documentation

QCA_EXPORT QTextStream & operator<< ( QTextStream &  stream,
const BigInteger &  b 
) [related]

Stream operator.

Parameters:
stream the stream to write to
b the integer to write to the stream

Definition at line 895 of file qca_tools.cpp.


The documentation for this class was generated from the following files:
  • qca_tools.h
  • qca_tools.cpp

qca

Skip menu "qca"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • akonadi
  • Decibel
  • eigen
  • Eigen2
  • kdewin32
  • Phonon
  •     Backend
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal