31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

integer<br />

integer<br />

a(const char ∗ s);<br />

a(const string& s);<br />

a creates an instance a of type integer from its decimal representation<br />

given by the string s.<br />

a creates an instance a of type integer from its decimal representation<br />

given by the string s.<br />

3. Operations<br />

<strong>The</strong> arithmetic operations +, −, ∗, /, + =, − =, ∗ =, / =, −(unary), ++, −−, the<br />

modulus operation (%, % =), bitwise AND (&, & =), bitwise OR (|, | =), the complement<br />

(˜), the shift operations (), the comparison operations =, ==, ! =<br />

and the stream operations all are available.<br />

int a.sign( ) returns the sign of a.<br />

int a.length( ) returns the number of bits of the representation of<br />

a.<br />

bool a.is long( ) returns whether a fits in the data type long.<br />

long a.to long( ) returns a long number which is initialized with the<br />

value of a. Precondition: a.is long() is true.<br />

double a.to double( ) returns a double floating point approximation of a.<br />

double<br />

a.to double(bool& is double)<br />

as above, but also returns in is double whether the<br />

conversion was exact.<br />

double a.to float( ) as above.<br />

string a.to string( ) returns the decimal representation of a.<br />

integer& a.from string(string s) sets a to the number that has decimal respresentation<br />

s.<br />

sz t a.used words( ) returns the length of the digit vector that represents<br />

a.<br />

digit a.highword( ) returns the most significant digit of a.<br />

digit a.contents(int i) returns the i-th digit of a (the first digit is<br />

a.contents(0)).<br />

void a.hex print(ostream& o) prints the digit vector that represents a in hex format<br />

to the output stream o.<br />

bool a.iszero( ) returns whether a is equal to zero.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!