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.

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

q. If the q is approximable by a normalized, finite<br />

floating point number, the error is 3ulps, i.e., three<br />

units in the last place.<br />

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

Non-member functions<br />

int sign(const rational& q) returns the sign of q.<br />

rational abs(const rational& q) returns the absolute value of q.<br />

rational sqr(const rational& q) returns the square of q.<br />

integer trunc(const rational& q) returns the integer with the next smaller absolute<br />

value.<br />

rational pow(const rational& q, int n)<br />

rational pow(const rational& q, integer a)<br />

returns the n-th power of q.<br />

returns the a-th power of q.<br />

integer floor(const rational& q) returns the next smaller integer.<br />

integer ceil(const rational& q) returns the next bigger integer.<br />

integer round(const rational& q) rounds q to the nearest integer.<br />

rational small rational between(const rational& p, const rational& q)<br />

returns a rational number between p and q whose<br />

denominator is as small as possible.<br />

rational<br />

small rational near(const rational& p, rational eps)<br />

returns a rational number between p − eps and<br />

p + eps whose denominator is as small as possible.<br />

4. Implementation<br />

A rational is implemented by two integer numbers which represent the numerator and<br />

the denominator. <strong>The</strong> sign is represented by the sign of the numerator.

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

Saved successfully!

Ooh no, something went wrong!