BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdldfp::DecimalUtil Struct Reference

#include <bdldfp_decimalutil.h>

Static Public Member Functions

static Decimal32 makeDecimalRaw32 (int significand, int exponent)
 
static Decimal64 makeDecimalRaw64 (int significand, int exponent)
 
static Decimal64 makeDecimalRaw64 (unsigned int significand, int exponent)
 
static Decimal64 makeDecimalRaw64 (long long significand, int exponent)
 
static Decimal64 makeDecimalRaw64 (unsigned long long significand, int exponent)
 
static Decimal128 makeDecimalRaw128 (int significand, int exponent)
 
static Decimal128 makeDecimalRaw128 (unsigned int significand, int exponent)
 
static Decimal128 makeDecimalRaw128 (long long significand, int exponent)
 
static Decimal128 makeDecimalRaw128 (unsigned long long significand, int exponent)
 
static Decimal64 makeDecimal64 (int significand, int exponent)
 
static Decimal64 makeDecimal64 (unsigned int significand, int exponent)
 
static Decimal64 makeDecimal64 (long long significand, int exponent)
 
static Decimal64 makeDecimal64 (unsigned long long significand, int exponent)
 
static int parseDecimal32 (Decimal32 *out, const char *str)
 
static int parseDecimal64 (Decimal64 *out, const char *str)
 
static int parseDecimal128 (Decimal128 *out, const char *str)
 
template<class STRING_TYPE >
static int parseDecimal32 (Decimal32 *out, const STRING_TYPE &str)
 
template<class STRING_TYPE >
static int parseDecimal64 (Decimal64 *out, const STRING_TYPE &str)
 
template<class STRING_TYPE >
static int parseDecimal128 (Decimal128 *out, const STRING_TYPE &str)
 
static int parseDecimal32Exact (Decimal32 *out, const char *str)
 
static int parseDecimal64Exact (Decimal64 *out, const char *str)
 
static int parseDecimal128Exact (Decimal128 *out, const char *str)
 
template<class STRING_TYPE >
static int parseDecimal32Exact (Decimal32 *out, const STRING_TYPE &str)
 
template<class STRING_TYPE >
static int parseDecimal64Exact (Decimal64 *out, const STRING_TYPE &str)
 
template<class STRING_TYPE >
static int parseDecimal128Exact (Decimal128 *out, const STRING_TYPE &str)
 
static Decimal32 copySign (Decimal32 x, Decimal32 y)
 
static Decimal64 copySign (Decimal64 x, Decimal64 y)
 
static Decimal128 copySign (Decimal128 x, Decimal128 y)
 
static Decimal32 exp (Decimal32 x)
 
static Decimal64 exp (Decimal64 x)
 
static Decimal128 exp (Decimal128 x)
 
static Decimal32 log (Decimal32 x)
 
static Decimal64 log (Decimal64 x)
 
static Decimal128 log (Decimal128 x)
 
static Decimal32 logB (Decimal32 x)
 
static Decimal64 logB (Decimal64 x)
 
static Decimal128 logB (Decimal128 x)
 
static Decimal32 log10 (Decimal32 x)
 
static Decimal64 log10 (Decimal64 x)
 
static Decimal128 log10 (Decimal128 x)
 
static Decimal32 fmod (Decimal32 x, Decimal32 y)
 
static Decimal64 fmod (Decimal64 x, Decimal64 y)
 
static Decimal128 fmod (Decimal128 x, Decimal128 y)
 
static Decimal32 remainder (Decimal32 x, Decimal32 y)
 
static Decimal64 remainder (Decimal64 x, Decimal64 y)
 
static Decimal128 remainder (Decimal128 x, Decimal128 y)
 
static long int lrint (Decimal32 x)
 
static long int lrint (Decimal64 x)
 
static long int lrint (Decimal128 x)
 
static long long int llrint (Decimal32 x)
 
static long long int llrint (Decimal64 x)
 
static long long int llrint (Decimal128 x)
 
static Decimal32 nextafter (Decimal32 from, Decimal32 to)
 
static Decimal64 nextafter (Decimal64 from, Decimal64 to)
 
static Decimal128 nextafter (Decimal128 from, Decimal128 to)
 
static Decimal32 nexttoward (Decimal32 from, Decimal128 to)
 
static Decimal64 nexttoward (Decimal64 from, Decimal128 to)
 
static Decimal128 nexttoward (Decimal128 from, Decimal128 to)
 
static Decimal32 pow (Decimal32 base, Decimal32 exp)
 
static Decimal64 pow (Decimal64 base, Decimal64 exp)
 
static Decimal128 pow (Decimal128 base, Decimal128 exp)
 
static Decimal32 fma (Decimal32 x, Decimal32 y, Decimal32 z)
 
static Decimal64 fma (Decimal64 x, Decimal64 y, Decimal64 z)
 
static Decimal128 fma (Decimal128 x, Decimal128 y, Decimal128 z)
 
static Decimal32 fabs (Decimal32 value)
 
static Decimal64 fabs (Decimal64 value)
 
static Decimal128 fabs (Decimal128 value)
 
static Decimal32 sqrt (Decimal32 x)
 
static Decimal64 sqrt (Decimal64 x)
 
static Decimal128 sqrt (Decimal128 x)
 
static int classify (Decimal32 x)
 
static int classify (Decimal64 x)
 
static int classify (Decimal128 x)
 
static bool isFinite (Decimal32 x)
 
static bool isFinite (Decimal64 x)
 
static bool isFinite (Decimal128 x)
 
static bool isInf (Decimal32 x)
 
static bool isInf (Decimal64 x)
 
static bool isInf (Decimal128 x)
 
static bool isNan (Decimal32 x)
 
static bool isNan (Decimal64 x)
 
static bool isNan (Decimal128 x)
 
static bool isNormal (Decimal32 x)
 
static bool isNormal (Decimal64 x)
 
static bool isNormal (Decimal128 x)
 
static bool isUnordered (Decimal32 x, Decimal32 y)
 
static bool isUnordered (Decimal64 x, Decimal64 y)
 
static bool isUnordered (Decimal128 x, Decimal128 y)
 
static Decimal32 ceil (Decimal32 x)
 
static Decimal64 ceil (Decimal64 x)
 
static Decimal128 ceil (Decimal128 x)
 Examples: ceil(0.5) ==> 1.0; ceil(-0.5) ==> 0.0.
 
static Decimal32 floor (Decimal32 x)
 
static Decimal64 floor (Decimal64 x)
 
static Decimal128 floor (Decimal128 x)
 Examples: floor(0.5) ==> 0.0; floor(-0.5) ==> -1.0.
 
static Decimal32 round (Decimal32 x)
 
static Decimal64 round (Decimal64 x)
 
static Decimal128 round (Decimal128 x)
 Examples: round(0.5) ==> 1.0; round(-0.5) ==> -1.0.
 
static long int lround (Decimal32 x)
 
static long int lround (Decimal64 x)
 
static long int lround (Decimal128 x)
 Examples: lround(0.5) ==> 1.0; lround(-0.5) ==> -1.0.
 
static Decimal32 round (Decimal32 x, unsigned int precision)
 
static Decimal64 round (Decimal64 x, unsigned int precision)
 
static Decimal128 round (Decimal128 x, unsigned int precision)
 Examples: round(3.14159, 3) ==> 3.142.
 
static Decimal32 trunc (Decimal32 x)
 
static Decimal64 trunc (Decimal64 x)
 
static Decimal128 trunc (Decimal128 x)
 Examples: trunc(0.5) ==> 0.0; trunc(-0.5) ==> 0.0.
 
static Decimal32 trunc (Decimal32 x, unsigned int precision)
 
static Decimal64 trunc (Decimal64 x, unsigned int precision)
 
static Decimal128 trunc (Decimal128 x, unsigned int precision)
 Examples: trunc(3.14159, 3) ==> 3.141.
 
static Decimal32 multiplyByPowerOf10 (Decimal32 value, int exponent)
 
static Decimal64 multiplyByPowerOf10 (Decimal64 value, int exponent)
 
static Decimal128 multiplyByPowerOf10 (Decimal128 value, int exponent)
 
static Decimal32 quantize (Decimal32 value, Decimal32 exponent)
 
static Decimal64 quantize (Decimal64 value, Decimal64 exponent)
 
static Decimal128 quantize (Decimal128 value, Decimal128 exponent)
 
static Decimal32 quantize (Decimal32 value, int exponent)
 
static Decimal64 quantize (Decimal64 value, int exponent)
 
static Decimal128 quantize (Decimal128 value, int exponent)
 
static int quantizeEqual (Decimal32 *x, Decimal32 y, int exponent)
 
static int quantizeEqual (Decimal64 *x, Decimal64 y, int exponent)
 
static int quantizeEqual (Decimal128 *x, Decimal128 y, int exponent)
 
static int quantum (Decimal32 value)
 
static int quantum (Decimal64 value)
 
static int quantum (Decimal128 value)
 
static bool sameQuantum (Decimal32 x, Decimal32 y)
 
static bool sameQuantum (Decimal64 x, Decimal64 y)
 
static bool sameQuantum (Decimal128 x, Decimal128 y)
 
static int decompose (int *sign, unsigned int *significand, int *exponent, Decimal32 value)
 
static int decompose (int *sign, bsls::Types::Uint64 *significand, int *exponent, Decimal64 value)
 
static int decompose (int *sign, Uint128 *significand, int *exponent, Decimal128 value)
 
static int format (char *buffer, int length, Decimal32 value, const DecimalFormatConfig &cfg=DecimalFormatConfig())
 
static int format (char *buffer, int length, Decimal64 value, const DecimalFormatConfig &cfg=DecimalFormatConfig())
 
static int format (char *buffer, int length, Decimal128 value, const DecimalFormatConfig &cfg=DecimalFormatConfig())
 

Detailed Description

This utility struct provides a namespace for functions using the decimal floating point types defined in the bdldfp_decimal package.

Member Function Documentation

◆ ceil() [1/3]

Decimal128 bdldfp::DecimalUtil::ceil ( Decimal128  x)
inlinestatic

◆ ceil() [2/3]

Decimal32 bdldfp::DecimalUtil::ceil ( Decimal32  x)
inlinestatic

Return the smallest integral value that is not less than the specified x.

Special value handling:

  • if x is quiet NaN, quiet NaN is returned.
  • If x is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • if x is +/-infinity or +/-0, it is returned unmodified.

◆ ceil() [3/3]

Decimal64 bdldfp::DecimalUtil::ceil ( Decimal64  x)
inlinestatic

◆ classify() [1/3]

static int bdldfp::DecimalUtil::classify ( Decimal128  x)
static

Note that the mention FP_XXX constants are C99 standard macros and they are defined in the math.h (cmath) standard header. On systems that fail to define those standard macros we define the in this component as public macros.

◆ classify() [2/3]

static int bdldfp::DecimalUtil::classify ( Decimal32  x)
static

Return the integer value that respresents the floating point classification of the specified x value as follows:

  • if x is NaN, return FP_NAN;
  • otherwise if x is positive or negative infinity, return FP_INFINITE;
  • otherwise if x is a subnormal value, return FP_SUBNORMAL
  • otherwise if x is a zero value, return FP_ZERO
  • otherwise return FP_NORMAL

◆ classify() [3/3]

static int bdldfp::DecimalUtil::classify ( Decimal64  x)
static

◆ copySign() [1/3]

Decimal128 bdldfp::DecimalUtil::copySign ( Decimal128  x,
Decimal128  y 
)
inlinestatic

Examples: copySign( 5.0, -2.0) ==> -5.0; copySign(-5.0, -2.0) ==> 5.0

◆ copySign() [2/3]

Decimal32 bdldfp::DecimalUtil::copySign ( Decimal32  x,
Decimal32  y 
)
inlinestatic

Return a decimal value with the magnitude of the specifed x and the sign of the specified y. If x is NaN, then NaN with the sign of y is returned.

◆ copySign() [3/3]

Decimal64 bdldfp::DecimalUtil::copySign ( Decimal64  x,
Decimal64  y 
)
inlinestatic

◆ decompose() [1/3]

static int bdldfp::DecimalUtil::decompose ( int *  sign,
bsls::Types::Uint64 significand,
int *  exponent,
Decimal64  value 
)
static

◆ decompose() [2/3]

static int bdldfp::DecimalUtil::decompose ( int *  sign,
Uint128 significand,
int *  exponent,
Decimal128  value 
)
static

Note that a decomposed representation may not be unique, for example 10 can be represented as either 10 * (10 ** 0) or 1 * (10 ** 1). The returned significand and exponent reflect the encoded representation of value (i.e., they reflect the quantum of value).

◆ decompose() [3/3]

static int bdldfp::DecimalUtil::decompose ( int *  sign,
unsigned int *  significand,
int *  exponent,
Decimal32  value 
)
static

Decompose the specified decimal value into the components of the decimal floating-point format and load the result into the specified sign, significand and exponent such that value is equal to sign * significand * (10 ** exponent). The special values infinity and NaNs are decomposed to sign, exponent and significand parts, even though they don't have their normal meaning (except sign). That is those specific values cannot be restored using these parts, unlike the finite ones. Return the integer value that represents the floating point classification of the specified value as follows:

  • if value is NaN, return FP_NAN;
  • if value is infinity, return FP_INFINITE;
  • if value is a subnormal value, return FP_SUBNORMAL;
  • if value is a zero value, return FP_ZERO;
  • otherwise return FP_NORMAL.

◆ exp() [1/3]

Decimal128 bdldfp::DecimalUtil::exp ( Decimal128  x)
inlinestatic

Special value handling:

  • If x is +/-0, 1 is returned.
  • If x is negative infinity, +0 is returned.
  • If x is +infinity, +infinity is returned.
  • If x is quiet NaN, quiet NaN is returned.
  • If x is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is finite, but the result value is outside the range of the return type, store the value of the macro ERANGE into errno and +infinity value is returned.

◆ exp() [2/3]

Decimal32 bdldfp::DecimalUtil::exp ( Decimal32  x)
inlinestatic

Return e (Euler's number, 2.7182818) raised to the specified power x.

◆ exp() [3/3]

Decimal64 bdldfp::DecimalUtil::exp ( Decimal64  x)
inlinestatic

◆ fabs() [1/3]

Decimal128 bdldfp::DecimalUtil::fabs ( Decimal128  value)
inlinestatic

Special value handling:

  • if x is NaN (either signaling or quiet), quiet NaN is returned.
  • if x is +/-infinity or +/-0, it is returned unmodified.

◆ fabs() [2/3]

Decimal32 bdldfp::DecimalUtil::fabs ( Decimal32  value)
inlinestatic

Return the absolute value of the specified x.

◆ fabs() [3/3]

Decimal64 bdldfp::DecimalUtil::fabs ( Decimal64  value)
inlinestatic

◆ floor() [1/3]

Decimal128 bdldfp::DecimalUtil::floor ( Decimal128  x)
inlinestatic

◆ floor() [2/3]

Decimal32 bdldfp::DecimalUtil::floor ( Decimal32  x)
inlinestatic

Return the largest integral value that is not greater than the specified x.

Special value handling:

  • if x is quiet NaN, quiet NaN is returned.
  • If x is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • if x is +/-infinity or +/-0, it is returned unmodified.

◆ floor() [3/3]

Decimal64 bdldfp::DecimalUtil::floor ( Decimal64  x)
inlinestatic

◆ fma() [1/3]

Decimal128 bdldfp::DecimalUtil::fma ( Decimal128  x,
Decimal128  y,
Decimal128  z 
)
inlinestatic

Special value handling:

  • If x or y are quiet NaN, quiet NaN is returned.
  • If any argument is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x*y is an exact infinity and z is an infinity with the opposite sign, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is zero and y is infinite or if x is infinite and y is zero, and z is not a NaN, then quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is zero and y is infinite or if x is infinite and y is zero, and z is NaN, then quiet NaN is returned.

◆ fma() [2/3]

Decimal32 bdldfp::DecimalUtil::fma ( Decimal32  x,
Decimal32  y,
Decimal32  z 
)
inlinestatic

Return, using the specified x, y, and z, the value of the expression x * y + z, rounded as one ternary operation according to the current decimal floating point rounding mode.

◆ fma() [3/3]

Decimal64 bdldfp::DecimalUtil::fma ( Decimal64  x,
Decimal64  y,
Decimal64  z 
)
inlinestatic

◆ fmod() [1/3]

Decimal128 bdldfp::DecimalUtil::fmod ( Decimal128  x,
Decimal128  y 
)
inlinestatic

Special value handling:

  • If either argument is quiet NaN, quiet NaN is returned.
  • If either argument is signaling NaN, quiet NaN is returned, and the value of the macro EDOM is stored into errno.
  • If x is +/-infnity and y is not NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is +/-0 and y is not zero, +/-0 is returned.
  • If y is +/-0, quite NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is finite and y is +/-infnity, x is returned.

◆ fmod() [2/3]

Decimal32 bdldfp::DecimalUtil::fmod ( Decimal32  x,
Decimal32  y 
)
inlinestatic

Return the remainder of the division of the specified x by the specified y. The returned value has the same sign as x and is less than y in magnitude.

◆ fmod() [3/3]

Decimal64 bdldfp::DecimalUtil::fmod ( Decimal64  x,
Decimal64  y 
)
inlinestatic

◆ format() [1/3]

static int bdldfp::DecimalUtil::format ( char *  buffer,
int  length,
Decimal128  value,
const DecimalFormatConfig cfg = DecimalFormatConfig() 
)
static

Format the specified value, placing the output in the buffer designated by the specified buffer and length, and return the length of the formatted value. If there is insufficient room in the buffer, its contents will be left in an unspecified state, with the returned value indicating the necessary size. This function does not write a terminating null character. If length is not positive, buffer is permitted to be null. This can be used to determine the necessary buffer size. Optionally specify a cfg, indicating formatting parameters. If cfg is not specified, then default configuration instance, indicating scientific notation style with a precision sufficient to produce all available digits is used. See the Attributes section for information on the configuration attributes.

Note that for some combinations of value and precision provided by cfg object, the number being written must first be rounded to fewer digits than it initially contains. The number written must be as close as possible to the initial value given the constraints on precision. The rounding should be done as "round-half-up", i.e., round up in magnitude when the first of the discarded digits is between 5 and 9.

Also note that if the configuration format attribute style is e_NATURAL then all significand digits of the value are output in the buffer regardless of the value specified in configuration's precision attribute.

◆ format() [2/3]

static int bdldfp::DecimalUtil::format ( char *  buffer,
int  length,
Decimal32  value,
const DecimalFormatConfig cfg = DecimalFormatConfig() 
)
static

◆ format() [3/3]

static int bdldfp::DecimalUtil::format ( char *  buffer,
int  length,
Decimal64  value,
const DecimalFormatConfig cfg = DecimalFormatConfig() 
)
static

◆ isFinite() [1/3]

static bool bdldfp::DecimalUtil::isFinite ( Decimal128  x)
static

Return true if the specified x is not an infinity value or NaN and false otherwise. Note that this is equivalent to classify(x) != FP_INFINITE && classify(x) != FP_NAN.

◆ isFinite() [2/3]

static bool bdldfp::DecimalUtil::isFinite ( Decimal32  x)
static

◆ isFinite() [3/3]

static bool bdldfp::DecimalUtil::isFinite ( Decimal64  x)
static

◆ isInf() [1/3]

static bool bdldfp::DecimalUtil::isInf ( Decimal128  x)
static

Return true if the specified x is an infinity value and false otherwise. Note that this is equivalent to classify(x) == FP_INFINITE.

◆ isInf() [2/3]

static bool bdldfp::DecimalUtil::isInf ( Decimal32  x)
static

◆ isInf() [3/3]

static bool bdldfp::DecimalUtil::isInf ( Decimal64  x)
static

◆ isNan() [1/3]

static bool bdldfp::DecimalUtil::isNan ( Decimal128  x)
static

Return true if the specified x is NaN and false otherwise. Note that this is equivalent to classify(x) == FP_NAN.

◆ isNan() [2/3]

static bool bdldfp::DecimalUtil::isNan ( Decimal32  x)
static

◆ isNan() [3/3]

static bool bdldfp::DecimalUtil::isNan ( Decimal64  x)
static

◆ isNormal() [1/3]

static bool bdldfp::DecimalUtil::isNormal ( Decimal128  x)
static

Return true if the specified x is a normal value and false otherwise. Note that this is equivalent to classify(x) == FP_NORMAL.

◆ isNormal() [2/3]

static bool bdldfp::DecimalUtil::isNormal ( Decimal32  x)
static

◆ isNormal() [3/3]

static bool bdldfp::DecimalUtil::isNormal ( Decimal64  x)
static

◆ isUnordered() [1/3]

static bool bdldfp::DecimalUtil::isUnordered ( Decimal128  x,
Decimal128  y 
)
static

Return true if either (or both) of the specified x and y arguments is a NaN, or false otherwise.

◆ isUnordered() [2/3]

static bool bdldfp::DecimalUtil::isUnordered ( Decimal32  x,
Decimal32  y 
)
static

◆ isUnordered() [3/3]

static bool bdldfp::DecimalUtil::isUnordered ( Decimal64  x,
Decimal64  y 
)
static

◆ llrint() [1/3]

long long int bdldfp::DecimalUtil::llrint ( Decimal128  x)
inlinestatic

◆ llrint() [2/3]

long long int bdldfp::DecimalUtil::llrint ( Decimal32  x)
inlinestatic

◆ llrint() [3/3]

long long int bdldfp::DecimalUtil::llrint ( Decimal64  x)
inlinestatic

◆ log() [1/3]

Decimal128 bdldfp::DecimalUtil::log ( Decimal128  x)
inlinestatic

Special value handling:

  • If x is +/-0, -infinity is returned and the value of the macro ERANGE is stored into errno.
  • If x is 1, +0 is returned.
  • If x is negative, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is +infinity, +infinity is returned.
  • If x is quiet NaN, quiet NaN is returned.
  • If x is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.

◆ log() [2/3]

Decimal32 bdldfp::DecimalUtil::log ( Decimal32  x)
inlinestatic

Return the natural (base e) logarithm of the specified x.

◆ log() [3/3]

Decimal64 bdldfp::DecimalUtil::log ( Decimal64  x)
inlinestatic

◆ log10() [1/3]

Decimal128 bdldfp::DecimalUtil::log10 ( Decimal128  x)
inlinestatic

Special value handling:

  • If x is +/-0, -infinity is returned and the value of the macro ERANGE is stored into errno.
  • If x is 1, +0 is returned.
  • If x is negative, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is +infinity, +infinity is returned.
  • If x is quiet NaN, quiet NaN is returned.
  • If x is signaling NaN, NaN is returned and the value of the macro EDOM is stored into errno.

◆ log10() [2/3]

Decimal32 bdldfp::DecimalUtil::log10 ( Decimal32  x)
inlinestatic

Return the common (base-10) logarithm of the specified x.

◆ log10() [3/3]

Decimal64 bdldfp::DecimalUtil::log10 ( Decimal64  x)
inlinestatic

◆ logB() [1/3]

Decimal128 bdldfp::DecimalUtil::logB ( Decimal128  x)
inlinestatic

Examples: logB( 10.0) ==> 1.0; logB(-100.0) ==> 2.0

◆ logB() [2/3]

Decimal32 bdldfp::DecimalUtil::logB ( Decimal32  x)
inlinestatic

Return the FLT_RADIX-based logarithm (i.e., base 10) of the absolute value of the specified x.

Special value handling:

  • If x is +/-0, -infinity is returned and the value of the macro ERANGE is stored into errno.
  • If x is 1, +0 is returned.
  • If x is +/-infinity, +infinity is returned.
  • If x is quiet NaN, quiet NaN is returned.
  • If x is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.

◆ logB() [3/3]

Decimal64 bdldfp::DecimalUtil::logB ( Decimal64  x)
inlinestatic

◆ lrint() [1/3]

long int bdldfp::DecimalUtil::lrint ( Decimal128  x)
inlinestatic

Special value handling:

  • The current rounding mode has no effect.
  • If either argument is quiet NaN, quiet NaN is returned.
  • If either argument is signaling NaN, quiet NaN is returned, and the value of the macro EDOM is stored into errno.
  • If y is +/-0, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is +/-infnity and y is not NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is finite and y is +/-infnity, x is returned.

◆ lrint() [2/3]

long int bdldfp::DecimalUtil::lrint ( Decimal32  x)
inlinestatic

◆ lrint() [3/3]

long int bdldfp::DecimalUtil::lrint ( Decimal64  x)
inlinestatic

◆ lround() [1/3]

long int bdldfp::DecimalUtil::lround ( Decimal128  x)
inlinestatic

◆ lround() [2/3]

long int bdldfp::DecimalUtil::lround ( Decimal32  x)
inlinestatic

Return the integral value nearest to the specified x. Round halfway cases away from zero, regardless of the current decimal floating point rounding mode.

Special value handling:

  • if x is NaN (either quiet or signaling), quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • if x is +/-infinity, quite NaN is returned and the value of the macro EDOM is stored into errno.
  • If the result of the rounding is outside the range of the return type, the macro EDOM is stored into errno.

◆ lround() [3/3]

long int bdldfp::DecimalUtil::lround ( Decimal64  x)
inlinestatic

◆ makeDecimal64() [1/4]

Decimal64 bdldfp::DecimalUtil::makeDecimal64 ( int  significand,
int  exponent 
)
inlinestatic

◆ makeDecimal64() [2/4]

Decimal64 bdldfp::DecimalUtil::makeDecimal64 ( long long  significand,
int  exponent 
)
inlinestatic

◆ makeDecimal64() [3/4]

Decimal64 bdldfp::DecimalUtil::makeDecimal64 ( unsigned int  significand,
int  exponent 
)
inlinestatic

◆ makeDecimal64() [4/4]

Decimal64 bdldfp::DecimalUtil::makeDecimal64 ( unsigned long long  significand,
int  exponent 
)
inlinestatic

◆ makeDecimalRaw128() [1/4]

Decimal128 bdldfp::DecimalUtil::makeDecimalRaw128 ( int  significand,
int  exponent 
)
inlinestatic

◆ makeDecimalRaw128() [2/4]

Decimal128 bdldfp::DecimalUtil::makeDecimalRaw128 ( long long  significand,
int  exponent 
)
inlinestatic

◆ makeDecimalRaw128() [3/4]

Decimal128 bdldfp::DecimalUtil::makeDecimalRaw128 ( unsigned int  significand,
int  exponent 
)
inlinestatic

◆ makeDecimalRaw128() [4/4]

Decimal128 bdldfp::DecimalUtil::makeDecimalRaw128 ( unsigned long long  significand,
int  exponent 
)
inlinestatic

Create a Deciaml128 object representing a decimal floating point number consisting of the specified significand and specified exponent, with the sign given by the significand (if signed). The behavior is undefined unless -6176 <= exponent <= 6111.

◆ makeDecimalRaw32()

Decimal32 bdldfp::DecimalUtil::makeDecimalRaw32 ( int  significand,
int  exponent 
)
inlinestatic

Create a Decimal32 object representing a decimal floating point number consisting of the specified significand and exponent, with the sign given by the significand (if signed). The behavior is undefined unless -9,999,999 <= significand <= 9,999,999 and -101 <= exponent <= 90.

◆ makeDecimalRaw64() [1/4]

Decimal64 bdldfp::DecimalUtil::makeDecimalRaw64 ( int  significand,
int  exponent 
)
inlinestatic

◆ makeDecimalRaw64() [2/4]

Decimal64 bdldfp::DecimalUtil::makeDecimalRaw64 ( long long  significand,
int  exponent 
)
inlinestatic

◆ makeDecimalRaw64() [3/4]

Decimal64 bdldfp::DecimalUtil::makeDecimalRaw64 ( unsigned int  significand,
int  exponent 
)
inlinestatic

◆ makeDecimalRaw64() [4/4]

Decimal64 bdldfp::DecimalUtil::makeDecimalRaw64 ( unsigned long long  significand,
int  exponent 
)
inlinestatic

Create a Decimal64 object representing a decimal floating point number consisting of the specified significand and exponent, with the sign given by the significand (if signed). The behavior is undefined unless -9,999,999,999,999,999 <= significand <= 9,999,999,999,999,999 and -398 <= exponent <= 369.

◆ multiplyByPowerOf10() [1/3]

Decimal128 bdldfp::DecimalUtil::multiplyByPowerOf10 ( Decimal128  value,
int  exponent 
)
inlinestatic

Special value handling:

  • If value is quiet NaN, quiet NaN is returned.
  • If value is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is infinite, then infinity is returned.
  • If a range error due to overflow occurs, infinity is returned and : the value of the macro ERANGE is stored into errno.

◆ multiplyByPowerOf10() [2/3]

Decimal32 bdldfp::DecimalUtil::multiplyByPowerOf10 ( Decimal32  value,
int  exponent 
)
inlinestatic

Return the result of multiplying the specified value by ten raised to the specified exponent. The quantum of value is scaled according to IEEE 754's scaleB operations.

◆ multiplyByPowerOf10() [3/3]

Decimal64 bdldfp::DecimalUtil::multiplyByPowerOf10 ( Decimal64  value,
int  exponent 
)
inlinestatic

◆ nextafter() [1/3]

Decimal128 bdldfp::DecimalUtil::nextafter ( Decimal128  from,
Decimal128  to 
)
inlinestatic

Return an integer value nearest to the specified x. Round x using the current rounding mode. If x is +/-infnity, NaN (either signaling or quiet) or the rounded value is outside the range of the return type, store the value of the macro EDOM into errno and return implementation-defined value.

◆ nextafter() [2/3]

Decimal32 bdldfp::DecimalUtil::nextafter ( Decimal32  from,
Decimal32  to 
)
inlinestatic

◆ nextafter() [3/3]

Decimal64 bdldfp::DecimalUtil::nextafter ( Decimal64  from,
Decimal64  to 
)
inlinestatic

◆ nexttoward() [1/3]

Decimal128 bdldfp::DecimalUtil::nexttoward ( Decimal128  from,
Decimal128  to 
)
inlinestatic

Special value handling:

  • If from equals to, to is returned.
  • If either argument is quiet NaN, quiet NaN is returned.
  • If either argument is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If from is finite, but the expected result is an infinity, infinity is returned and the value of the macro ERANGE is stored into errno.
  • If from does not equal to and the result is subnormal or zero, the value of the macro ERANGE is stored into errno.

◆ nexttoward() [2/3]

Decimal32 bdldfp::DecimalUtil::nexttoward ( Decimal32  from,
Decimal128  to 
)
inlinestatic

Return the next representable value of the specified from in the direction of the specified to.

◆ nexttoward() [3/3]

Decimal64 bdldfp::DecimalUtil::nexttoward ( Decimal64  from,
Decimal128  to 
)
inlinestatic

◆ parseDecimal128() [1/2]

static int bdldfp::DecimalUtil::parseDecimal128 ( Decimal128 out,
const char *  str 
)
static

Return a DecimalNN object that has the specified significand and exponent, rounded according to the current decimal rounding mode, if necessary. If an overflow condition occurs, store the value of the macro ERANGE into errno and return infinity with the appropriate sign.

◆ parseDecimal128() [2/2]

template<class STRING_TYPE >
int bdldfp::DecimalUtil::parseDecimal128 ( Decimal128 out,
const STRING_TYPE &  str 
)
inlinestatic

Load into the specified out the decimal floating point number described by the specified str; return zero if the conversion was successful and non-zero otherwise. The value of out is unspecified if the function returns a non-zero value. The parameterized STRING_TYPE must be one of bsl::string, std::string, std::pmr::string (if supported), or bslstl::StringRef.

◆ parseDecimal128Exact() [1/2]

static int bdldfp::DecimalUtil::parseDecimal128Exact ( Decimal128 out,
const char *  str 
)
static

◆ parseDecimal128Exact() [2/2]

template<class STRING_TYPE >
int bdldfp::DecimalUtil::parseDecimal128Exact ( Decimal128 out,
const STRING_TYPE &  str 
)
inlinestatic

Load into the specified out the decimal floating point number described by the specified str. Return 0 if out is an exact representation of str, a positive value if str is an approximation of str (i.e., str could not be represented exactly), and a negative value if str could not be parsed. The value of out is unspecified if the function returns a negative value. The parameterized STRING_TYPE must be one of bsl::string, std::string, std::pmr::string (if supported), or bslstl::StringRef.

◆ parseDecimal32() [1/2]

static int bdldfp::DecimalUtil::parseDecimal32 ( Decimal32 out,
const char *  str 
)
static

◆ parseDecimal32() [2/2]

template<class STRING_TYPE >
int bdldfp::DecimalUtil::parseDecimal32 ( Decimal32 out,
const STRING_TYPE &  str 
)
inlinestatic

◆ parseDecimal32Exact() [1/2]

static int bdldfp::DecimalUtil::parseDecimal32Exact ( Decimal32 out,
const char *  str 
)
static

◆ parseDecimal32Exact() [2/2]

template<class STRING_TYPE >
int bdldfp::DecimalUtil::parseDecimal32Exact ( Decimal32 out,
const STRING_TYPE &  str 
)
inlinestatic

◆ parseDecimal64() [1/2]

static int bdldfp::DecimalUtil::parseDecimal64 ( Decimal64 out,
const char *  str 
)
static

◆ parseDecimal64() [2/2]

template<class STRING_TYPE >
int bdldfp::DecimalUtil::parseDecimal64 ( Decimal64 out,
const STRING_TYPE &  str 
)
inlinestatic

◆ parseDecimal64Exact() [1/2]

static int bdldfp::DecimalUtil::parseDecimal64Exact ( Decimal64 out,
const char *  str 
)
static

◆ parseDecimal64Exact() [2/2]

template<class STRING_TYPE >
int bdldfp::DecimalUtil::parseDecimal64Exact ( Decimal64 out,
const STRING_TYPE &  str 
)
inlinestatic

◆ pow() [1/3]

Decimal128 bdldfp::DecimalUtil::pow ( Decimal128  base,
Decimal128  exp 
)
inlinestatic

Special value handling:

  • If base is finite and negative and exp is finite and non-integer, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • If the mathematical result of this function is infinity or undefined or a range error due to overflow occurs, infinity is returned and the value of the macro ERANGE is stored into errno.
  • If a range error occurs due to underflow, the correct result (after rounding) is returned and the value of the macro ERANGE is stored into errno.
  • If either argument is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.

◆ pow() [2/3]

Decimal32 bdldfp::DecimalUtil::pow ( Decimal32  base,
Decimal32  exp 
)
inlinestatic

Return the value of the specified base raised to the power of the specified exp.

◆ pow() [3/3]

Decimal64 bdldfp::DecimalUtil::pow ( Decimal64  base,
Decimal64  exp 
)
inlinestatic

◆ quantize() [1/6]

Decimal128 bdldfp::DecimalUtil::quantize ( Decimal128  value,
Decimal128  exponent 
)
inlinestatic

Return a number equal to the specified value (except for possible rounding) having the exponent equal to the exponent of the specified exponent. Rounding may occur when the exponent is greater than the quantum of value. E.g., quantize(147e-2_d32, 1e-1_d32) yields 15e-1_d32. In the opposite direction, if exponent is sufficiently less than the quantum of value, it may not be possible to construct the requested result, and if so, NaN is returned. E.g., quantize(1234567e0_d32, 1e-1_d32) returns NaN.

◆ quantize() [2/6]

Decimal128 bdldfp::DecimalUtil::quantize ( Decimal128  value,
int  exponent 
)
inlinestatic

Return a number equal to the specified value (except for possible rounding) having the specified exponent. Rounding may occur when exponent is greater than the quantum of value. E.g., quantize(147e-2_d32, -1) yields 15e-1_d32. In the opposite direction, if exponent is sufficiently less than the quantum of value, it may not be possible to construct the requested result, and if so, NaN is returned. E.g., quantize(1234567e0_d32, -1) returns NaN. Behavior is undefined unless the exponent satisfies the following conditions

  • for Decimal32 type: -101 <= exponent <= 90
  • for Decimal64 type: -398 <= exponent <= 369
  • for Decimal128 type: -6176 <= exponent <= 6111

◆ quantize() [3/6]

Decimal32 bdldfp::DecimalUtil::quantize ( Decimal32  value,
Decimal32  exponent 
)
inlinestatic

◆ quantize() [4/6]

Decimal32 bdldfp::DecimalUtil::quantize ( Decimal32  value,
int  exponent 
)
inlinestatic

◆ quantize() [5/6]

Decimal64 bdldfp::DecimalUtil::quantize ( Decimal64  value,
Decimal64  exponent 
)
inlinestatic

◆ quantize() [6/6]

Decimal64 bdldfp::DecimalUtil::quantize ( Decimal64  value,
int  exponent 
)
inlinestatic

◆ quantizeEqual() [1/3]

int bdldfp::DecimalUtil::quantizeEqual ( Decimal128 x,
Decimal128  y,
int  exponent 
)
inlinestatic

Example: Decimal32 x; BSLS_ASSERT(0 == quantizeEqual(&x, 123e+3_d32, 2); BSLS_ASSERT(1230e+2_d32 == x); BSLS_ASSERT(0 != quantizeEqual(&x, 123e+3_d32, -2); BSLS_ASSERT(1230e+2_d32 == x);

◆ quantizeEqual() [2/3]

int bdldfp::DecimalUtil::quantizeEqual ( Decimal32 x,
Decimal32  y,
int  exponent 
)
inlinestatic

If a floating-point number equal to the specified y and having the specified exponent can be constructed, set that value into the specified x and return 0. Otherwise, or if y is NaN or infinity, leave the contents of x unchanged and return a non-zero value. The behavior is undefined unless exponent satisfies the following conditions

  • for Decimal32 type: -101 <= exponent <= 90
  • for Decimal64 type: -398 <= exponent <= 369
  • for Decimal128 type: -6176 <= exponent <= 6111

◆ quantizeEqual() [3/3]

int bdldfp::DecimalUtil::quantizeEqual ( Decimal64 x,
Decimal64  y,
int  exponent 
)
inlinestatic

◆ quantum() [1/3]

static int bdldfp::DecimalUtil::quantum ( Decimal128  value)
static

Return an integer equal to the exponent field in the specified value. Each decimal floating point number is a representation of the ideal form s * (10 ** e), where s is significand and e is exponent. This function returns that exponent value. The behavior is undefined if value is NaN or value is infinity.

◆ quantum() [2/3]

static int bdldfp::DecimalUtil::quantum ( Decimal32  value)
static

◆ quantum() [3/3]

static int bdldfp::DecimalUtil::quantum ( Decimal64  value)
static

◆ remainder() [1/3]

Decimal128 bdldfp::DecimalUtil::remainder ( Decimal128  x,
Decimal128  y 
)
inlinestatic

◆ remainder() [2/3]

Decimal32 bdldfp::DecimalUtil::remainder ( Decimal32  x,
Decimal32  y 
)
inlinestatic

Return the remainder of the division of the specified x by the specified y. The remainder of the division operation x/y calculated by this function is exactly the value x - n*y, where n s the integral value nearest the exact value x/y. When |n - x/y| == 0.5, the value n is chosen to be even. Note that in contrast to DecimalImpUtil::fmod(), the returned value is not guaranteed to have the same sign as x.

◆ remainder() [3/3]

Decimal64 bdldfp::DecimalUtil::remainder ( Decimal64  x,
Decimal64  y 
)
inlinestatic

◆ round() [1/6]

Decimal128 bdldfp::DecimalUtil::round ( Decimal128  x)
inlinestatic

◆ round() [2/6]

Decimal128 bdldfp::DecimalUtil::round ( Decimal128  x,
unsigned int  precision 
)
inlinestatic

◆ round() [3/6]

Decimal32 bdldfp::DecimalUtil::round ( Decimal32  x)
inlinestatic

Return the integral value nearest to the specified x. Round halfway cases away from zero, regardless of the current decimal floating point rounding mode.

Special value handling:

  • if x is quiet NaN, quiet NaN is returned.
  • If x is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • if x is +/-infinity or +/-0, it is returned unmodified.

◆ round() [4/6]

Decimal32 bdldfp::DecimalUtil::round ( Decimal32  x,
unsigned int  precision 
)
inlinestatic

Return the specified x value rounded to the specified precision decimal places. Round halfway cases away from zero, regardless of the current decimal floating point rounding mode. If x is integral, positive zero, negative zero, NaN, or infinity then return x itself.

◆ round() [5/6]

Decimal64 bdldfp::DecimalUtil::round ( Decimal64  x)
inlinestatic

◆ round() [6/6]

Decimal64 bdldfp::DecimalUtil::round ( Decimal64  x,
unsigned int  precision 
)
inlinestatic

◆ sameQuantum() [1/3]

bool bdldfp::DecimalUtil::sameQuantum ( Decimal128  x,
Decimal128  y 
)
inlinestatic

Return true if the specified x and y values have the same quantum exponents, and false otherwise. If both arguments are NaN or both arguments are infinity, they have the same quantum exponents. Note that if exactly one operand is NaN or exactly one operand is infinity, they do not have the same quantum exponents.

◆ sameQuantum() [2/3]

bool bdldfp::DecimalUtil::sameQuantum ( Decimal32  x,
Decimal32  y 
)
inlinestatic

◆ sameQuantum() [3/3]

bool bdldfp::DecimalUtil::sameQuantum ( Decimal64  x,
Decimal64  y 
)
inlinestatic

◆ sqrt() [1/3]

Decimal128 bdldfp::DecimalUtil::sqrt ( Decimal128  x)
inlinestatic

Special value handling:

  • If x is NaN, NaN is returned.
  • If x is less than -0, NaN is returned and the value of the macro EDOM is stored into errno.
  • If x is +/-infinity or +/-0, it is returned unmodified.

◆ sqrt() [2/3]

Decimal32 bdldfp::DecimalUtil::sqrt ( Decimal32  x)
inlinestatic

Return the square root of the specified x.

◆ sqrt() [3/3]

Decimal64 bdldfp::DecimalUtil::sqrt ( Decimal64  x)
inlinestatic

◆ trunc() [1/6]

Decimal128 bdldfp::DecimalUtil::trunc ( Decimal128  x)
inlinestatic

◆ trunc() [2/6]

static Decimal128 bdldfp::DecimalUtil::trunc ( Decimal128  x,
unsigned int  precision 
)
static

◆ trunc() [3/6]

Decimal32 bdldfp::DecimalUtil::trunc ( Decimal32  x)
inlinestatic

Return the nearest integral value that is not greater in absolute value than the specified x.

Special value handling:

  • if x is quiet NaN, quiet NaN is returned.
  • If x is signaling NaN, quiet NaN is returned and the value of the macro EDOM is stored into errno.
  • if x is +/-infinity or +/-0, it is returned unmodified.

◆ trunc() [4/6]

static Decimal32 bdldfp::DecimalUtil::trunc ( Decimal32  x,
unsigned int  precision 
)
static

Return the specified x value truncated to the specified precision decimal places. Round towards zero, regardless of the current decimal floating point rounding mode. If precision of x is less than or equal the precision or x is positive zero, negative zero, NaN, or infinity then return x itself.

◆ trunc() [5/6]

Decimal64 bdldfp::DecimalUtil::trunc ( Decimal64  x)
inlinestatic

◆ trunc() [6/6]

static Decimal64 bdldfp::DecimalUtil::trunc ( Decimal64  x,
unsigned int  precision 
)
static

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