#include <bdldfp_decimal.h>
List of all members.
Detailed Description
This value-semantic class implements the IEEE-754 64 bit decimal floating-point format arithmetic type. This class is a standard layout type that is const
thread-safe and exception-neutral.
See Component bdldfp_decimal
Constructor & Destructor Documentation
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
|
) |
|
Create a Decimal64_Type
object having the value positive zero and the smallest exponent value.
IMPLICIT: Create a Decimal64_Type
object having the specified value
.
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
Decimal32 |
other |
) |
|
IMPLICIT: Create a Decimal64_Type
object having the value of the specified other
following the conversion rules as defined by IEEE-754:
-
If
other
is NaN, initialize this object to a NaN.
-
Otherwise if
other
is infinity (positive or negative), then initialize this object to infinity with the same sign.
-
Otherwise if
other
is zero, then initialize this object to zero with the same sign.
-
Otherwise initialize this object to the value of the
other
.
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
Decimal128 |
other |
) |
[explicit] |
Create a Decimal64_Type
object having the value closest to the value of the specified other
following the conversion rules as defined by IEEE-754:
-
If
other
is NaN, initialize this object to a NaN.
-
Otherwise if
other
is infinity (positive or negative), then initialize this object to infinity with the same sign.
-
Otherwise if
other
is zero, then initialize this object to zero with the same sign.
-
Otherwise if
other
has an absolute value that is larger than std::numeric_limits<Decimal64>max()
then store the value of the macro ERANGE
into errno
and initialize this object to infinity with the same sign as other
.
-
Otherwise if
other
has an absolute value that is smaller than std::numeric_limits<Decimal64>min()
then store the value of the macro ERANGE
into errno
and initialize this object to zero with the same sign as other
.
-
Otherwise if
other
has a value that has more significant digits than std::numeric_limits<Decimal64>max_digit
then initialize this object to the value of other
rounded according to the rounding direction.
-
Otherwise initialize this object to the value as the
other
.
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
float |
other |
) |
[explicit] |
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
double |
other |
) |
[explicit] |
Create a Decimal64_Type
object having the value closest to the value of the specified other
value. Warning: clients requiring a conversion for an exact decimal value should use bdldfp_decimalconvertutil
(see WARNING: Conversions from float
and double
}. This conversion follows the conversion rules as defined by IEEE-754:
-
If
other
is NaN, initialize this object to a NaN.
-
Otherwise if
other
is infinity (positive or negative), then initialize this object to infinity value with the same sign.
-
Otherwise if
other
has a zero value, then initialize this object to zero with the same sign.
-
Otherwise if
other
has a value that needs more than std::numeric_limits<Decimal64>max_digit
significant decimal digits to represent then initialize this object to the value of other
rounded according to the rounding direction.
-
Otherwise initialize this object to the value of the
other
.
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
int |
other |
) |
[explicit] |
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
unsigned int |
other |
) |
[explicit] |
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
long |
other |
) |
[explicit] |
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
unsigned long |
other |
) |
[explicit] |
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
long long |
other |
) |
[explicit] |
bdldfp::Decimal_Type64::Decimal_Type64 |
( |
unsigned long long |
other |
) |
[explicit] |
Create a Decimal64_Type
object having the value closest to the value of the specified other
following the conversion rules as defined by IEEE-754:
-
Otherwise if
other
has a value that is not exactly representable using std::numeric_limits<Decimal64>max_digit
decimal digits then initialize this object to the value of other
rounded according to the rounding direction.
-
Otherwise initialize this object to the value of
other
with exponent 0.
bdldfp::Decimal_Type64::~Decimal64_Type |
( |
|
) |
|
Member Function Documentation
static int bdldfp::Decimal_Type64::maxSupportedBdexVersion |
( |
|
) |
[static] |
static int bdldfp::Decimal_Type64::maxSupportedBdexVersion |
( |
int |
versionSelector |
) |
[static] |
Return the maximum valid BDEX format version, as indicated by the specified versionSelector
, to be passed to the bdexStreamOut
method. Note that it is highly recommended that versionSelector
be formatted as "YYYYMMDD", a date representation. Also note that versionSelector
should be a compile-time-chosen value that selects a format version supported by both externalizer and unexternalizer. See the bslx
package-level documentation for more information on BDEX streaming of value-semantic types and containers.
bdldfp::Decimal_Type64::Decimal64_Type |
( |
const Decimal64_Type & |
original |
) |
|
Create a Decimal64_Type
object that is a copy of the specified original
as defined by the copy
operation of IEEE-754 2008:
-
If
other
is NaN, initialize this object to a NaN.
-
Otherwise initialize this object to the value of the
other
.
Note that since floating-point types may be NaN, and NaNs are unordered (do not compare equal even to themselves) it is possible that a copy of a decimal will not compare equal to the original; however it will behave as the original.
Decimal64_Type& bdldfp::Decimal_Type64::operator= |
( |
const Decimal64_Type & |
rhs |
) |
|
Make this object a copy of the specified rhs
as defined by the copy
operation of IEEE-754 2008 and return a reference providing modifiable access to this object.
-
If
other
is NaN, set this object to a NaN.
-
Otherwise set this object to the value of the
other
.
Note that since floating-point types may be NaN, and NaNs are unordered (do not compare equal even to themselves) it is possible that, after an assignment, a decimal will not compare equal to the original; however it will behave as the original.
Add 1.0 to the value of this object and return a reference to it. Note that this is a floating-point value so this operation may not change the value of this object at all (if the value is large) or it may just set it to 1.0 (if the original value is small).
Add -1.0 to the value of this object and return a reference to it. Note that this is a floating-point value so this operation may not change the value of this object at all (if the value is large) or it may just set it to -1.0 (if the original value is small).
Add the value of the specified rhs
object to the value of this as described by IEEE-754, store the result in this object, and return a reference to this object.
-
If either of this object or
rhs
is signaling NaN, then store the value of the macro EDOM
into errno
and set this object to a NaN.
-
Otherwise if either of this object or
rhs
is NaN then set this object to a NaN.
-
Otherwise if this object and
rhs
have infinite values of differing signs, store the value of the macro EDOM
into errno
and set this object to a NaN.
-
Otherwise if this object and
rhs
have infinite values of the same sign, then do not change this object.
-
Otherwise if
rhs
has a zero value (positive or negative), do not change this object.
-
Otherwise if the sum of this object and
rhs
has an absolute value that is larger than std::numeric_limits<Decimal64>max()
then store the value of the macro ERANGE
into errno
and set this object to infinity with the same sign as that result.
-
Otherwise set this object to the sum of the number represented by
rhs
and the number represented by this object.
Note that this is a floating-point value so this operations may not change the value of this object at all (if the value is large) or it may seem to update it to the value of the other
(if the original value is small).
Note that when rhs
is a Decimal128
, this operation is always performed with 128 bits precision to prevent loss of precision of the rhs
operand (prior to the operation). The result is then rounded back to 64 bits and stored to this object. See IEEE-754 2008, 5.1, first paragraph, second sentence for specification.
Decimal_Type64& bdldfp::Decimal_Type64::operator+= |
( |
unsigned int |
rhs |
) |
|
Decimal_Type64& bdldfp::Decimal_Type64::operator+= |
( |
unsigned long |
rhs |
) |
|
Decimal_Type64& bdldfp::Decimal_Type64::operator+= |
( |
unsigned long long |
rhs |
) |
|
Add the specified rhs
to the value of this object as described by IEEE-754, store the result in this object, and return a reference to this object.
-
If this object is signaling NaN, then store the value of the macro
EDOM
into errno
and set this object to a NaN.
-
Otherwise if this object is NaN, then do not change this object.
-
Otherwise if this object is infinity, then do not change it.
-
Otherwise if the sum of this object and
rhs
has an absolute value that is larger than std::numeric_limits<Decimal64>max()
then store the value of the macro ERANGE
into errno
and set this object to infinity with the same sign as that result.
-
Otherwise set this object to sum of adding
rhs
and the number represented by this object.
Note that this is a floating-point value so this operations may not change the value of this object at all (if the value is large) or it may seem to update it to the value of the other
(if the original value is small).
Subtract the value of the specified rhs
from the value of this object as described by IEEE-754, store the result in this object, and return a reference to this object.
-
If this object is signaling NaN, then store the value of the macro
EDOM
into errno
and set this object to a NaN.
-
Otherwise if either of this object or
rhs
is NaN then set this object to a NaN.
-
Otherwise if this object and
rhs
have infinity value of the same signs, store the value of the macro EDOM
into errno
and set this object to a NaN.
-
Otherwise if this object and the
rhs
have infinite values of differing signs, then do not change this object.
-
Otherwise if the
rhs
has a zero value (positive or negative), do not change this object.
-
Otherwise if subtracting the value of the
rhs
object from this results in an absolute value that is larger than std::numeric_limits<Decimal64>max()
then store the value of the macro ERANGE
into errno
and set this object to infinity with the same sign as that result.
-
Otherwise set this object to the result of subtracting the value of
rhs
from the value of this object.
Note that this is a floating-point value so this operations may not change the value of this object at all (if the value is large) or it may seem to update it to the value of the other
(if the original value is small).
Note that when rhs
is a Decimal128
, this operation is always performed with 128 bits precision to prevent loss of precision of the rhs
operand (prior to the operation). The result is then rounded back to 64 bits and stored to this object. See IEEE-754 2008, 5.1, first paragraph, second sentence for specification.
Decimal_Type64& bdldfp::Decimal_Type64::operator-= |
( |
unsigned int |
rhs |
) |
|
Decimal_Type64& bdldfp::Decimal_Type64::operator-= |
( |
unsigned long |
rhs |
) |
|
Decimal_Type64& bdldfp::Decimal_Type64::operator-= |
( |
unsigned long long |
rhs |
) |
|
Subtract the specified rhs
from the value of this object as described by IEEE-754, store the result in this object, and return a reference to this object.
-
If this object is signaling NaN, then store the value of the macro
EDOM
into errno
and set this object to a NaN.
-
Otherwise if this object is NaN, then do not change this object.
-
Otherwise if this object is infinity, then do not change it.
-
Otherwise if subtracting
rhs
from this object's value results in an absolute value that is larger than std::numeric_limits<Decimal64>max()
then store the value of the macro ERANGE
into errno
and set this object to infinity with the same sign as that result.
-
Otherwise set this object to the result of subtracting
rhs
from the value of this object.
Note that this is a floating-point value so this operations may not change the value of this object at all (if the value is large) or it may seem to update it to the value of the other
(if the original value is small).
Multiply the value of the specified rhs
object by the value of this as described by IEEE-754, store the result in this object, and return a reference to this object.
-
If either of this object or
rhs
is signaling NaN, then store the value of the macro EDOM
into errno
and set this object to a NaN.
-
Otherwise if either of this object or
rhs
is NaN then set this object to a NaN.
-
Otherwise, if one of this object and
rhs
is zero (positive or negative) and the other is infinity (positive or negative), store the value of the macro EDOM
into errno
and set this object to a NaN.
-
Otherwise, if either this object or
rhs
is positive or negative infinity, set this object to infinity. The sign of this object will be positive if this object and rhs
had the same sign, and negative otherwise.
-
Otherwise, if either this object or
rhs
is zero, set this object to zero. The sign of this object will be positive if this object and rhs
had the same sign, and negative otherwise.
-
Otherwise if the product of this object and
rhs
has an absolute value that is larger than std::numeric_limits<Decimal64>max()
then store the value of the macro ERANGE
into errno
and set this object to infinity with the same sign of that result.
-
Otherwise if the product of this object and
rhs
has an absolute value that is smaller than std::numeric_limits<Decimal64>min()
then store the value of the macro ERANGE
into errno
and set this object to zero value with the same sign as that result.
-
Otherwise set this object to the product of the value of
rhs
and the value of this object.
Note that when rhs
is a Decimal128
, this operation is always performed with 128 bits precision to prevent loss of precision of the rhs
operand (prior to the operation). The result is then rounded back to 64 bits and stored to this object. See IEEE-754 2008, 5.1, first paragraph, second sentence for specification.
Decimal_Type64& bdldfp::Decimal_Type64::operator*= |
( |
unsigned int |
rhs |
) |
|
Decimal_Type64& bdldfp::Decimal_Type64::operator*= |
( |
unsigned long |
rhs |
) |
|
Decimal_Type64& bdldfp::Decimal_Type64::operator*= |
( |
unsigned long long |
rhs |
) |
|
Multiply the specified rhs
by the value of this object as described by IEEE-754, store the result in this object, and return a reference to this object.
-
If this object is signaling NaN, then store the value of the macro
EDOM
into errno
and set this object to a NaN.
-
Otherwise if this object is NaN, then do not change this object.
-
Otherwise if this object is infinity (positive or negative), and
rhs
is zero, then store the value of the macro EDOM
into errno
and set this object to a NaN.
-
Otherwise if this object is infinity (positive or negative), then do not change it.
-
Otherwise if
rhs
is zero, then set this object to zero with the same sign as its value had prior to this operation.
-
Otherwise if the product of
rhs
and the value of this object results in an absolute value that is larger than std::numeric_limits<Decimal64>max()
then store the value of the macro ERANGE
into errno
and set this object to infinity with the same sign as that result.
-
Otherwise if the product of
rhs
and the value of this object results in an absolute value that is smaller than std::numeric_limits<Decimal64>min()
then store the value of the macro ERANGE
into errno
and set this object to zero with the same sign as that result.
Divide the value of this object by the value of the specified rhs
as described by IEEE-754, store the result in this object, and return a reference to this object.
-
If either of this object or
rhs
is signaling NaN, then store the value of the macro EDOM
into errno
and set this object to a NaN.
-
Otherwise if either of this object or
rhs
is NaN then set this object to a NaN.
-
Otherwise if this object and
rhs
are both infinity (positive or negative) or both zero (positive or negative), then store the value of the macro EDOM
into errno
and return a NaN.
-
Otherwise if
rhs
has a positive zero value, then store the value of the macro ERANGE
into errno
and set this object to infinity with the same sign as its original value.
-
Otherwise if
rhs
has a negative zero value, then store the value of the macro ERANGE
into errno
and set this object to infinity with the opposite sign as its original value.
-
Otherwise if dividing the value of this object by the value of
rhs
results in an absolute value that is larger than std::numeric_limits<Decimal64>max()
then store the value of the macro ERANGE
into errno
and return infinity with the same sign as that result.
-
Otherwise if dividing the value of this object by the value of
rhs
results in an absolute value that is smaller than std::numeric_limits<Decimal64>min()
then store the value of the macro ERANGE
into 'errno'and return zero with the same sign as that result.
-
Otherwise set this object to the result of dividing the value of this object by the value of
rhs
.
Note that when rhs
is a Decimal128
, this operation is always performed with 128 bits precision to prevent loss of precision of the rhs
operand (prior to the operation). The result is then rounded back to 64 bits and stored to this object. See IEEE-754 2008, 5.1, first paragraph, second sentence for specification.
Decimal_Type64& bdldfp::Decimal_Type64::operator/= |
( |
unsigned int |
rhs |
) |
|
Decimal_Type64& bdldfp::Decimal_Type64::operator/= |
( |
unsigned long |
rhs |
) |
|
Decimal_Type64& bdldfp::Decimal_Type64::operator/= |
( |
unsigned long long |
rhs |
) |
|
Divide the value of this object by the specified rhs
as described by IEEE-754, store the result in this object, and return a reference to this object.
-
If this object is signaling NaN, then store the value of the macro
EDOM
into errno
and set this object to a NaN.
-
Otherwise if this object is NaN then set this object to a NaN.
-
Otherwise if this object is infinity (positive or negative) and
rhs
is positive value then set this object to infinity value with the same sign as its original value.
-
Otherwise if this object is infinity (positive or negative) and
rhs
is negative value then set this object to infinity value with the opposite sign as its original value.
-
Otherwise if
rhs
is zero, store the value of the macro ERANGE
into errno
and set this object to infinity with the same sign it had prior to this operation.
-
Otherwise if dividing the value of this object by the value of
rhs
results in an absolute value that is larger than std::numeric_limits<Decimal64>max()
then store the value of the macro ERANGE
into errno
and return infinity with the same sign as that result.
-
Otherwise if dividing the value of this object by the value of
rhs
results in an absolute value that is smaller than std::numeric_limits<Decimal64>min()
then store the value of the macro ERANGE
into 'errno'and return zero with the same sign as that result.
-
Otherwise set this object to the result of dividing the value of this object by the value of
rhs
.
Return a modifiable pointer to the underlying implementation.
template<class STREAM >
STREAM& bdldfp::Decimal_Type64::bdexStreamIn |
( |
STREAM & |
stream, |
|
|
int |
version | |
|
) |
| | |
Assign to this object the value read from the specified input stream
using the specified version
format, and return a reference to stream
. If stream
is initially invalid, this operation has no effect. If version
is not supported, this object is unaltered and stream
is invalidated, but otherwise unmodified. If version
is supported but stream
becomes invalid during this operation, this object has an undefined, but valid, state. Note that no version is read from stream
. See the bslx
package-level documentation for more information on BDEX streaming of value-semantic types and containers.
Return a non-modifiable pointer to the underlying implementation.
Return the value of the underlying implementation.
template<class STREAM >
STREAM& bdldfp::Decimal_Type64::bdexStreamOut |
( |
STREAM & |
stream, |
|
|
int |
version | |
|
) |
| | const |
Write the value of this object, using the specified version
format, to the specified output stream
, and return a reference to stream
. If stream
is initially invalid, this operation has no effect. If version
is not supported, stream
is invalidated, but otherwise unmodified. Note that version
is not written to stream
. See the bslx
package-level documentation for more information on BDEX streaming of value-semantic types and containers.
bsl::ostream& bdldfp::Decimal_Type64::print |
( |
bsl::ostream & |
stream, |
|
|
int |
level = 0 , |
|
|
int |
spacesPerLevel = 4 | |
|
) |
| | const |
Write the value of this object to the specified output stream
in a human-readable format, and return a reference to stream
. Optionally specify an initial indentation level
, whose absolute value is incremented recursively for nested objects. If level
is specified, optionally specify spacesPerLevel
, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level
is negative, suppress indentation of the first line. If spacesPerLevel
is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level
). If stream
is not valid on entry, this operation has no effect. Note that this human-readable format is not fully specified, and can change without notice.
The documentation for this class was generated from the following file: