More patches to QxtCurrency

1. Added static "null()" method to construct a null currency value easily.
2. Fixed "has_quiet_NaN" value (it has one, so should have been true).
3. Missed a "CURRENCY" reference for Windows, now "CY" like the others.
This commit is contained in:
Dee Holtsclaw 2012-05-05 16:10:13 -04:00
parent d9c173e768
commit 9c248be03d
2 changed files with 12 additions and 5 deletions

View File

@ -49,7 +49,7 @@
* decimal places with an effective range of
* \bold -922,337,203,685,477.5807 to \bold 922,337,203,685,477.5807
* (inclusive). The actual lowest value is reserved to indicate a NULL
* status. This type is equivalent to the CURRENCY type in Microsoft
* status. This type is equivalent to the CY / CURRENCY type in Microsoft
* Windows and support for these values is provided in that environment.
*
* Specializations for \c std::abs and \c std::numeric_limits are

View File

@ -190,6 +190,8 @@ public:
// Miscellany
// Get null value
static QxtCurrency null();
// Get absolute value
QxtCurrency abs() const;
// Clamp value to a range
@ -267,7 +269,7 @@ namespace std {
{
return v.abs();
}
/*! Numeric limits information for QiCurrency class. Essentially the
/*! Numeric limits information for QxtCurrency class. Essentially the
* same as std::numeric_limits<long long>
*/
template<>
@ -301,7 +303,7 @@ namespace std {
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_quiet_NaN = true;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
@ -335,6 +337,11 @@ inline void QxtCurrency::setNull()
value = std::numeric_limits<QxtCurrency>::quiet_NaN().value;
}
inline QxtCurrency QxtCurrency::null()
{
return std::numeric_limits<QxtCurrency>::quiet_NaN();
}
inline QxtCurrency QxtCurrency::abs() const
{
if(*this)
@ -365,9 +372,9 @@ inline QxtCurrency::operator int() const
}
#if defined(qdoc) || defined(Q_OS_WIN32)
inline QxtCurrency::operator CURRENCY() const
inline QxtCurrency::operator CY() const
{
CURRENCY result;
CY result;
result.int64 = normalized().value;
return result;
}