Calculator Step 6

- Main Page
- Classes
- Files

- File List
- File Members

Classes | Functions
number.hpp File Reference
`#include <memory>`
`#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.

150 {
151 return not (a == b);
152 }

number operator- | ( | number | n | ) |
| inline

Negate a number.

Parameters

  n | the number

Returns
  -`n`

Definition at line 202 of file number.hpp.

203 {
204 return number{0} - n;
205 }
number
Definition: number.hpp:16

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().

161 {
162 return a.less(b);
163 }
number::less
bool less(number b)
Definition: number.cpp:70

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().

212 {
213 n.print(stream);
214 return stream;
215 }
number::print
void print(std::ostream &stream)
Definition: number.cpp:51

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.

172 {
173 return not(b < a);
174 }

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().

139 {
140 return a.equals(b);
141 }
number::equals
bool equals(number b)
Definition: number.cpp:64

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.

183 {
184 return b < a;
185 }

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.

194 {
195 return not (a < b);
196 }