RWDecimalPortableRWDecimalBase
Data Types | |
enum RoundingMethod |
#include <rw/db/decport.h> RWDecimalPortable dec; // construct a decimal == 0 dec = "1.23"; // construct a decimal == 1.23
RWDecimalPortable represents an arbitrary precision decimal fraction.
RWDecimalBase contains the following enum, used by the round() method:
enum RoundingMethod { PLAIN = 0, UP = 1, DOWN = 2,
BANKERS = 3, TRUNCATE = 2 };
Rounding methods are defined as follows:
PLAIN: Round up on a tie. For example, 1.25 rounds to 1.3, 1.35 rounds to 1.4, 1.251 becomes 1.3.
UP: Always round up. For example, 1.25 rounds to 1.3, 1.35 rounds to 1.4, and 1.251 becomes 1.3.
DOWN: Always round down. For example, 1.25 rounds to 1.2, 1.35 rounds to 1.3, and 1.251 rounds to 1.2.
BANKERS: On a tie, round so that last digit is even. For example, 1.25 rounds to 1.2, 1.35 rounds to 1.4, and 1.251 (which is not a tie) rounds to 1.3.
TRUNCATE: Same as DOWN.
RWDecimalPortable();
The default constructor creates a value initialized to zero (0).
RWDecimalPortable(const char* input);
Parses input, which must be recognizable as a decimal number. Embedded commas to separate groups of digits are allowed. Negation may be expressed by a minus sign or with parentheses.
RWDecimalPortable(long intPart);
Constructs a value with intPart as the part before the decimal point.
operator RWCString();
Returns self as an RWCString. For example, format is -23.21 or 0.32 or 432.
virtual RWspace binaryStoreSize() const;
Returns the number of bytes required to store self using the saveOn() methods.
friend unsigned hash() const;
Returns a value suitable for hashing.
RWBoolean isNumber() const;
Returns FALSE if self represents a NaN, a missing value, or a NULL; otherwise returns TRUE. Note: In this instance, the mathematical rather than the RDBMS meaning of NULL is intended. Please see the entry for class RWDBNullIndicator.
friend void restoreFrom(RWFile& file);
Reads file, replacing the contents of self.
friend void restoreFrom(RWvistream& vis);
Reads vis, replacing the contents of self.
friend void saveOn(RWFile& file) const;
Writes the contents of self to file.
friend void saveOn(RWvostream& vos) const;
Writes the contents of self to vos.
void trimZeros();
Removes leading zeros before self's decimal point and trailing zeros after.
RWDecimalPortable round(const RWDecimalPortable&, int digits, RoundingMethod = RWDecimalBase::PLAIN);
Returns an RWDecimalPortable which is the result of rounding self according to the applied specifications.
double toDouble(const RWDecimalPortable&);
Returns a double which approximates the value of self.
RWDecimalPortable operator-(const RWDecimalPortable&); RWDecimalPortable operator+(const RWDecimalPortable&, const RWDecimalPortable&); RWDecimalPortable operator-(const RWDecimalPortable&, const RWDecimalPortable&); RWDecimalPortable operator*(const RWDecimalPortable&, const RWDecimalPortable&);
Rudimentary math functions. These are not very efficient. For efficiency, use one of the decimal classes of Money.h++.
RWBoolean operator==(const RWDecimalPortable& x, const RWDecimalPortable& y); RWBoolean operator>=(const RWDecimalPortable& x, const RWDecimalPortable& y); RWBoolean operator!=(const RWDecimalPortable& x, const RWDecimalPortable& y); RWBoolean operator<(const RWDecimalPortable& x, const RWDecimalPortable& y); RWBoolean operator>(const RWDecimalPortable& x, const RWDecimalPortable& y); RWBoolean operator<=(const RWDecimalPortable& x, const RWDecimalPortable& y);
Relational operators.
ostream& operator<<(ostream&, const RWDecimalPortable&);
Writes an RWDecimalPortable to an output stream.
ostream& operator>>(istream&, RWDecimalPortable&);
Reads an RWDecimalPortable from an input stream.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.