- Main Page
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# number_double Class Reference

`#include <number_impl.hpp>`

Inheritance diagram for number_double:

List of all members.

## Public Member Functions
| number_double (double value)
double | value () const
virtual number_impl * | promote_to_void ()
## Private Member Functions
virtual std::string | do_to_string () const
virtual void | do_save (std::ostream &stream) const
virtual bool | do_equals (number_impl const &rhs) const
virtual bool | do_less (number_impl const &rhs) const
virtual number_impl * | do_add (number_impl const &rhs)
virtual number_impl * | do_subtract (number_impl const &rhs)
virtual number_impl * | do_multiply (number_impl const &rhs)
virtual number_impl * | do_divide (number_impl const &rhs)
virtual number_impl * | do_promote (number_impl &rhs) const
## Private Attributes
double | value_

## Detailed Description

Represent a floating-point value. Always use `double` to represent floating-point values.

Definition at line 144 of file number_impl.hpp.

## Constructor & Destructor Documentation

number_double::number_double | ( | double | value | ) | `[inline]`

Definition at line 146 of file number_impl.hpp.

Referenced by do_add(), do_divide(), do_multiply(), and do_subtract().

    00146 : number_impl(), value_(value) {}

## Member Function Documentation

double number_double::value | ( |  | ) | const`[inline]`

Definition at line 147 of file number_impl.hpp.

References value_.

Referenced by do_add(), do_divide(), do_equals(), do_less(), do_multiply(), do_save(), do_subtract(), and do_to_string().

    00147 { return value_; }

number_impl * number_double::promote_to_void | ( |  | ) | `[virtual]`

Reimplemented from number_impl.

Definition at line 403 of file number_impl.cpp.

    00404 {
    00405   return new number_void();
    00406 }

std::string number_double::do_to_string | ( |  | ) | const`[private, virtual]`

Implements number_impl.

Definition at line 348 of file number_impl.cpp.

References value().

    00350 {
    00351   std::ostringstream stream;
    00352   stream << value();
    00353   return stream.str();
    00354 }

void number_double::do_save | ( | std::ostream & | stream | ) | const`[private, virtual]`

Implements number_impl.

Definition at line 356 of file number_impl.cpp.

References value().

    00358 {
    00359   stream << "double " << value() << ' ';
    00360 }

bool number_double::do_equals | ( | number_impl const & | rhs | ) | const`[private, virtual]`

Implements number_impl.

Definition at line 362 of file number_impl.cpp.

References value().

    00364 {
    00365   return value() == dynamic_cast<number_double const&>(rhs).value();
    00366 }

bool number_double::do_less | ( | number_impl const & | rhs | ) | const`[private, virtual]`

Implements number_impl.

Definition at line 368 of file number_impl.cpp.

References value().

    00370 {
    00371   return value() < dynamic_cast<number_double const&>(rhs).value();
    00372 }

number_impl * number_double::do_add | ( | number_impl const & | rhs | ) | `[private, virtual]`

Implements number_impl.

Definition at line 374 of file number_impl.cpp.

References number_double(), value(), and value_.

    00375 {
    00376   return new number_double(value_ + dynamic_cast<number_double const&>(rhs).value());
    00377 }

number_impl * number_double::do_subtract | ( | number_impl const & | rhs | ) | `[private, virtual]`

Implements number_impl.

Definition at line 379 of file number_impl.cpp.

References number_double(), value(), and value_.

    00380 {
    00381   return new number_double(value_ - dynamic_cast<number_double const&>(rhs).value());
    00382 }

number_impl * number_double::do_multiply | ( | number_impl const & | rhs | ) | `[private, virtual]`

Implements number_impl.

Definition at line 384 of file number_impl.cpp.

References number_double(), value(), and value_.

    00385 {
    00386   return new number_double(value_ * dynamic_cast<number_double const&>(rhs).value());
    00387 }

number_impl * number_double::do_divide | ( | number_impl const & | rhs | ) | `[private, virtual]`

Implements number_impl.

Definition at line 389 of file number_impl.cpp.

References number_double(), value(), and value_.

    00390 {
    00391   double right = dynamic_cast<number_double const&>(rhs).value();
    00392   if (right == 0.0)
    00393     throw calc_error("division by zero");
    00394   return new number_double(value_ / right);
    00395 }

number_impl * number_double::do_promote | ( | number_impl & | rhs | ) | const`[private, virtual]`

Implements number_impl.

Definition at line 397 of file number_impl.cpp.

References number_impl::promote_to_double().

    00399 {
    00400   return rhs.promote_to_double();
    00401 }

## Member Data Documentation

double number_double::value_`[private]`

Definition at line 160 of file number_impl.hpp.

Referenced by do_add(), do_divide(), do_multiply(), do_subtract(), and value().

The documentation for this class was generated from the following files:

- number_impl.hpp
- number_impl.cpp