- Main Page
- Classes
- Files

# number.hpp File Reference

`#include <ostream>`
`#include <string>`
`#include "rational.hpp"`

Go to the source code of this file.

## Classes
class | number
## Functions
bool | operator== (number a, number b)
bool | operator!= (number a, number b)
bool | operator< (number a, number b)
bool | operator<= (number a, number b)
bool | operator> (number a, number b)
bool | operator>= (number a, number b)
number | operator- (number n)
std::ostream & | operator<< (std::ostream &stream, number n)

## Function Documentation

bool operator!= | ( | number | a,
|  | number | b |
| ) |  |  | `[inline]`

Compare two number objects for numeric inequality. The objects are coerced to a common type before comparing.

Parameters:

  | a | The left-hand operand
  | b | The right-hand operand

Returns:
  true if a != b (watch out for floating-point comparisons).

Definition at line 149 of file number.hpp.

    00150 {
    00151   return not (a == b);
    00152 }

number operator- | ( | number | n | ) | `[inline]`

Negate a number.

Parameters:

  | n | the number

Returns:
  -`n`

Definition at line 202 of file number.hpp.

    00203 {
    00204   return number(0) - n;
    00205 }

bool operator< | ( | number | a,
|  | number | b |
| ) |  |  | `[inline]`

Compare two number objects for numeric less-than. The objects are coerced to a common type before comparing.

Parameters:

  | a | The left-hand operand
  | b | The right-hand operand

Returns:
  true if a < b (watch out for floating-point comparisons).

Definition at line 160 of file number.hpp.

References number::less().

    00161 {
    00162   return a.less(b);
    00163 }

std::ostream& operator<< | ( | std::ostream & | stream,
|  | number | n |
| ) |  |  | `[inline]`

Print a number

Parameters:

  | stream | The output stream
  | n | The number to print

Definition at line 211 of file number.hpp.

References number::print().

    00212 {
    00213   n.print(stream);
    00214   return stream;
    00215 }

bool operator<= | ( | number | a,
|  | number | b |
| ) |  |  | `[inline]`

Compare two number objects for numeric less-than-or-equal. The objects are coerced to a common type before comparing.

Parameters:

  | a | The left-hand operand
  | b | The right-hand operand

Returns:
  true if a <= b (watch out for floating-point comparisons).

Definition at line 171 of file number.hpp.

    00172 {
    00173   return not(b < a);
    00174 }

bool operator== | ( | number | a,
|  | number | b |
| ) |  |  | `[inline]`

Compare two number objects for numeric equality. The objects are coerced to a common type before comparing.

Parameters:

  | a | The left-hand operand
  | b | The right-hand operand

Returns:
  true if a == b (watch out for floating-point comparisons).

Definition at line 138 of file number.hpp.

References number::equals().

    00139 {
    00140   return a.equals(b);
    00141 }

bool operator> | ( | number | a,
|  | number | b |
| ) |  |  | `[inline]`

Compare two number objects for numeric greater-than. The objects are coerced to a common type before comparing.

Parameters:

  | a | The left-hand operand
  | b | The right-hand operand

Returns:
  true if a > b (watch out for floating-point comparisons).

Definition at line 182 of file number.hpp.

    00183 {
    00184   return b < a;
    00185 }

bool operator>= | ( | number | a,
|  | number | b |
| ) |  |  | `[inline]`

Compare two number objects for numeric greater-than-or-equal. The objects are coerced to a common type before comparing.

Parameters:

  | a | The left-hand operand
  | b | The right-hand operand

Returns:
  true if a >= b (watch out for floating-point comparisons).

Definition at line 193 of file number.hpp.

    00194 {
    00195   return not (a < b);
    00196 }