Quick Links:

bal | bbl | bdl | bsl

Public Member Functions | Static Public Member Functions

bdldfp::Decimal_Type128 Class Reference

#include <bdldfp_decimal.h>

List of all members.

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (Decimal_Type128, bsl::is_trivially_copyable)
 Decimal_Type128 ()
 Decimal_Type128 (DecimalImpUtil::ValueType128 value)
 Decimal_Type128 (Decimal32 value)
 Decimal_Type128 (Decimal64 value)
 Decimal_Type128 (float other)
 Decimal_Type128 (double other)
 Decimal_Type128 (int value)
 Decimal_Type128 (unsigned int value)
 Decimal_Type128 (long value)
 Decimal_Type128 (unsigned long value)
 Decimal_Type128 (long long value)
 Decimal_Type128 (unsigned long long value)
 Decimal128_Type (const Decimal128_Type &original)
 ~Decimal128_Type ()
Decimal128_Type & operator= (const Decimal128_Type &rhs)
Decimal_Type128operator++ ()
Decimal_Type128operator-- ()
Decimal_Type128operator+= (Decimal32 rhs)
Decimal_Type128operator+= (Decimal64 rhs)
Decimal_Type128operator+= (Decimal128 rhs)
Decimal_Type128operator+= (int rhs)
Decimal_Type128operator+= (unsigned int rhs)
Decimal_Type128operator+= (long rhs)
Decimal_Type128operator+= (unsigned long rhs)
Decimal_Type128operator+= (long long rhs)
Decimal_Type128operator+= (unsigned long long rhs)
Decimal_Type128operator-= (Decimal32 rhs)
Decimal_Type128operator-= (Decimal64 rhs)
Decimal_Type128operator-= (Decimal128 rhs)
Decimal_Type128operator-= (int rhs)
Decimal_Type128operator-= (unsigned int rhs)
Decimal_Type128operator-= (long rhs)
Decimal_Type128operator-= (unsigned long rhs)
Decimal_Type128operator-= (long long rhs)
Decimal_Type128operator-= (unsigned long long rhs)
Decimal_Type128operator*= (Decimal32 rhs)
Decimal_Type128operator*= (Decimal64 rhs)
Decimal_Type128operator*= (Decimal128 rhs)
Decimal_Type128operator*= (int rhs)
Decimal_Type128operator*= (unsigned int rhs)
Decimal_Type128operator*= (long rhs)
Decimal_Type128operator*= (unsigned long rhs)
Decimal_Type128operator*= (long long rhs)
Decimal_Type128operator*= (unsigned long long rhs)
Decimal_Type128operator/= (Decimal32 rhs)
Decimal_Type128operator/= (Decimal64 rhs)
Decimal_Type128operator/= (Decimal128 rhs)
Decimal_Type128operator/= (int rhs)
Decimal_Type128operator/= (unsigned int rhs)
Decimal_Type128operator/= (long rhs)
Decimal_Type128operator/= (unsigned long rhs)
Decimal_Type128operator/= (long long rhs)
Decimal_Type128operator/= (unsigned long long rhs)
DecimalImpUtil::ValueType128data ()
template<class STREAM >
STREAM & bdexStreamIn (STREAM &stream, int version)
const
DecimalImpUtil::ValueType128
data () const
DecimalImpUtil::ValueType128 value () const
template<class STREAM >
STREAM & bdexStreamOut (STREAM &stream, int version) const

Static Public Member Functions

static int maxSupportedBdexVersion ()
static int maxSupportedBdexVersion (int versionSelector)

Detailed Description

This value-semantic class implements the IEEE-754 128 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_Type128::Decimal_Type128 (  ) 

Create a Decimal128_Type object having the value positive zero and the smallest exponent value.

bdldfp::Decimal_Type128::Decimal_Type128 ( DecimalImpUtil::ValueType128  value  ) 

IMPLICIT: Create a Decimal128_Type object having the specified value.

bdldfp::Decimal_Type128::Decimal_Type128 ( Decimal32  value  ) 

IMPLICIT:

bdldfp::Decimal_Type128::Decimal_Type128 ( Decimal64  value  ) 

IMPLICIT: Create a Decimal128_Type object having the specified value, subject to the conversion rules as defined by IEEE-754:

  • If value is NaN, initialize this object to a NaN.
  • Otherwise if value is infinity, then initialize this object to infinity with the same sign.
  • Otherwise if value is zero, then initialize this object to zero with the same sign.
  • Otherwise initialize this object to value.
bdldfp::Decimal_Type128::Decimal_Type128 ( float  other  )  [explicit]
bdldfp::Decimal_Type128::Decimal_Type128 ( double  other  )  [explicit]

Create a Decimal128_Type object having the value closest to 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 value is NaN, initialize this object to a NaN.
  • Otherwise if value is infinity, then initialize this object to infinity value with the same sign.
  • Otherwise if value has a zero value, then initialize this object to zero with the same sign.
  • Otherwise initialize this object to value.
bdldfp::Decimal_Type128::Decimal_Type128 ( int  value  )  [explicit]
bdldfp::Decimal_Type128::Decimal_Type128 ( unsigned int  value  )  [explicit]
bdldfp::Decimal_Type128::Decimal_Type128 ( long  value  )  [explicit]
bdldfp::Decimal_Type128::Decimal_Type128 ( unsigned long  value  )  [explicit]
bdldfp::Decimal_Type128::Decimal_Type128 ( long long  value  )  [explicit]
bdldfp::Decimal_Type128::Decimal_Type128 ( unsigned long long  value  )  [explicit]

Create a Decimal128_Type object having the value closest to the specified value subject to the conversion rules as defined by IEEE-754:

  • If value has an absolute value that is larger than std::numeric_limits<Decimal128>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 value has a value that is not exactly representable using std::numeric_limits<Decimal128>max_digit decimal digits then initialize this object to the value of value rounded according to the rounding direction.
  • Otherwise initialize this object to value with exponent 0.
bdldfp::Decimal_Type128::~Decimal128_Type (  ) 

Destroy this object.


Member Function Documentation

static int bdldfp::Decimal_Type128::maxSupportedBdexVersion (  )  [static]
static int bdldfp::Decimal_Type128::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_Type128::BSLMF_NESTED_TRAIT_DECLARATION ( Decimal_Type128  ,
bsl::is_trivially_copyable   
)
bdldfp::Decimal_Type128::Decimal128_Type ( const Decimal128_Type &  original  ) 

Create a Decimal128_Type object that is a copy of the specified original as defined by the copy operation of IEEE-754 2008:

  • If original is NaN, initialize this object to a NaN.
  • Otherwise initialize this object to the value of the original.

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.

Decimal128_Type& bdldfp::Decimal_Type128::operator= ( const Decimal128_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 rhs 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.

Decimal_Type128& bdldfp::Decimal_Type128::operator++ (  ) 

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).

Decimal_Type128& bdldfp::Decimal_Type128::operator-- (  ) 

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).

Decimal_Type128& bdldfp::Decimal_Type128::operator+= ( Decimal32  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator+= ( Decimal64  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator+= ( Decimal128  rhs  ) 

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 infinity value 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<Decimal128>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).

Decimal_Type128& bdldfp::Decimal_Type128::operator+= ( int  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator+= ( unsigned int  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator+= ( long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator+= ( unsigned long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator+= ( long long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::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<Decimal128>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).

Decimal_Type128& bdldfp::Decimal_Type128::operator-= ( Decimal32  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator-= ( Decimal64  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator-= ( Decimal128  rhs  ) 

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<Decimal128>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).

Decimal_Type128& bdldfp::Decimal_Type128::operator-= ( int  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator-= ( unsigned int  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator-= ( long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator-= ( unsigned long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator-= ( long long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::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<Decimal128>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).

Decimal_Type128& bdldfp::Decimal_Type128::operator*= ( Decimal32  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator*= ( Decimal64  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator*= ( Decimal128  rhs  ) 

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<Decimal128>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<Decimal128>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.
Decimal_Type128& bdldfp::Decimal_Type128::operator*= ( int  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator*= ( unsigned int  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator*= ( long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator*= ( unsigned long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator*= ( long long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::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<Decimal128>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<Decimal128>min() then store the value of the macro ERANGE into errno and set this object to zero with the same sign as that result.
  • Otherwise set this object to the product of the value of this object and the value rhs.
Decimal_Type128& bdldfp::Decimal_Type128::operator/= ( Decimal32  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator/= ( Decimal64  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator/= ( Decimal128  rhs  ) 

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<Decimal128>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<Decimal128>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.
Decimal_Type128& bdldfp::Decimal_Type128::operator/= ( int  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator/= ( unsigned int  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator/= ( long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator/= ( unsigned long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::operator/= ( long long  rhs  ) 
Decimal_Type128& bdldfp::Decimal_Type128::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<Decimal128>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<Decimal128>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.
DecimalImpUtil::ValueType128* bdldfp::Decimal_Type128::data (  ) 

Return a modifiable pointer to the underlying implementation.

template<class STREAM >
STREAM& bdldfp::Decimal_Type128::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.

const DecimalImpUtil::ValueType128* bdldfp::Decimal_Type128::data (  )  const

Return a non-modifiable pointer to the underlying implementation.

DecimalImpUtil::ValueType128 bdldfp::Decimal_Type128::value (  )  const

Return the value of the underlying implementation.

template<class STREAM >
STREAM& bdldfp::Decimal_Type128::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.


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