Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress C++ API Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::Decimal

Group:  Core Numeric Types


Does not inherit

Local Index

Members

Header File

#include rwsf/core/Decimal.h

Description

This class represents an arbitrary precision decimal fraction. The representation is not exposed via member functions for accessing the strings representing the pieces before and after the decimal. This is done because it might make sense to one day replace this implementation with an arbitrary precision integer-based implementation.

The concept of trailing zeros after the decimal place is supported. If you construct an rwsf::Decimal using the string constructor and have trailing zeros (e.g., 1.200), then you are guaranteed that the string conversion operator will return a string with these trailing zeros. Rounding supports the concept of trailing zeros, so round("1.2",2) yields 1.20. The math functions (+-*) truncate trailing zeros. Use trimZeros() to strip off the excess zeros. Note that because trailing zeroes are allowed the relation x==y does not guarantee that std::string(x)==stdstring(y) since "1.200"=="1.2".

Public Data Members

const Decimal missing;
const Decimal NaN;
const Decimal null;

Public Constructors

Decimal(const char * s);
Decimal(const std::string & s);
Decimal(long);
Decimal(int);
Decimal();

Public Static Member Functions

std::string
decimalSeparator();

Public Member Functions

std::string
asString() const;
std::string
asString(const rwsf::Locale &) const;
unsigned
hash() const;
bool
isNumber() const;
bool
isZero();
size_t
numSignificantDigits() const;
size_t
precision() const;
size_t
scale() const;
void
trimZeros();

Public Operators

const Decimal &
operator *=(const Decimal & rhs);
const Decimal &
operator+=(const Decimal & rhs);
const Decimal &
operator-=(const Decimal & rhs);


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.