BDE 4.14.0 Production release
|
#include <bdldfp_decimalimputil.h>
Public Types | |
enum | { k_STATUS_INEXACT = Imp::k_STATUS_INEXACT , k_STATUS_UNDERFLOW = Imp::k_STATUS_UNDERFLOW , k_STATUS_OVERFLOW = Imp::k_STATUS_OVERFLOW } |
typedef Imp::ValueType32 | ValueType32 |
typedef Imp::ValueType64 | ValueType64 |
typedef Imp::ValueType128 | ValueType128 |
This struct
provides a namespace for utility functions that implement core decimal floating-poing operations.
typedef Imp::ValueType128 bdldfp::DecimalImpUtil::ValueType128 |
typedef Imp::ValueType32 bdldfp::DecimalImpUtil::ValueType32 |
typedef Imp::ValueType64 bdldfp::DecimalImpUtil::ValueType64 |
|
inlinestatic |
lhs
or rhs
is signaling NaN, then store the value of the macro EDOM
into errno
and return a NaN.lhs
or rhs
is NaN, return a NaN.lhs
and rhs
are infinities of differing signs, store the value of the macro EDOM
into errno
and return a NaN.lhs
and rhs
are infinities of the same sign then return infinity of that sign.rhs
is zero (positive or negative), return lhs
.lhs
and rhs
has an absolute value that is larger than the maximum value supported by the indicated result type then store the value of the macro ERANGE
into errno
and return infinity with the same sign as that result.lhs
and the number represented by rhs
.
|
inlinestatic |
Add the value of the specified rhs
to the value of the specified lhs
as described by IEEE-754 and return the result.
|
inlinestatic |
|
inlinestatic |
value
is signaling NaN, store the value of the macro EDOM
into errno
and return signaling NaN value.value
is NaN, return a NaN.value
is infinity (positive or negative), then return an object equal to infinity with the same sign.value
is a zero value, then return an object equal to zero with the same sign.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 return infinity with the same sign as value
.value
has an absolute value that is smaller than std::numeric_limits<Decimal128>::min()
then store the value of the macro ERANGE
into errno
and return a zero with the same sign as value
.value
needs more than std::numeric_limits<Decimal128>::max_digit
significant decimal digits to represent then return the value
rounded according to the rounding direction.Decimal128
object representing value
.
|
inlinestatic |
Create a Decimal128
object having the value closest to the specified value
following the conversion rules as defined by IEEE-754:
|
inlinestatic |
value
is signaling NaN, store the value of the macro EDOM
into errno
and return signaling NaN value.value
is NaN, return a NaN.value
is infinity (positive or negative), then return an object equal to infinity with the same sign.value
is a zero value, then return an object equal to zero with the same sign.value
has an absolute value that is larger than std::numeric_limits<Decimal32>::max()
then store the value of the macro ERANGE
into errno
and return infinity with the same sign as value
.value
has an absolute value that is smaller than std::numeric_limits<Decimal32>::min()
then store the value of the macro ERANGE
into errno
and return a zero with the same sign as value
.value
needs more than std::numeric_limits<Decimal32>::max_digit
significant decimal digits to represent then return the value
rounded according to the rounding direction.Decimal32
object representing value
.
|
inlinestatic |
Create a Decimal32
object having the value closest to the specified value
following the conversion rules as defined by IEEE-754:
|
inlinestatic |
value
is signaling NaN, store the value of the macro EDOM
into errno
and return signaling NaN value.value
is NaN, return a NaN.value
is infinity (positive or negative), then return an object equal to infinity with the same sign.value
is a zero value, then return an object equal to zero with the same sign.value
needs more than std::numeric_limits<Decimal64>::max_digit
significant decimal digits to represent then return the value
rounded according to the rounding direction.Decimal64
object representing value
.
|
inlinestatic |
Create a Decimal64
object having the value closest to the specified value
following the conversion rules as defined by IEEE-754:
|
inlinestatic |
|
inlinestatic |
Return the smallest integral value that is not less than the specified x
.
Special value handling:
x
is quiet NaN, quiet NaN is returned.x
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +/-infinity or +/-0, it is returned unmodified.
|
inlinestatic |
|
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.
|
static |
Return the integer value that respresents the floating point classification of the specified x
value as follows:
x
is NaN, return FP_NAN;x
is positive or negative infinity, return FP_INFINITE
;x
is a subnormal value, return FP_SUBNORMAL
x
is a zero value, return FP_ZERO
FP_NORMAL
|
static |
|
inlinestatic |
|
inlinestatic |
Return a DecimalStorage::TypeXX
representing the specified value
in Densely Packed Decimal (DPD) format. This format is compatible with the IBM compiler's native type.
|
inlinestatic |
|
inlinestatic |
Return a ValueTypeXX
representing the specified dpd
, which is currently in Densely Packed Decimal (DPD) format. This format is compatible with the IBM compiler's native type.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return a ValueTypeXX
representing the specified bid
, which is currently in Binary Integral Decimal (BID) format. This format is compatible with the Intel DFP implementation type.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return a DecimalStorage::TypeXX
representing the specified value
in Binary Integral Decimal (BID) format. This format is compatible with the Intel DFP implementation type.
|
inlinestatic |
|
inlinestatic |
Convert the specified input
to the closest value of the indicated result type following the conversion rules as defined by IEEE-754:
|
inlinestatic |
input
is signaling NaN, store the value of the macro EDOM
into errno
and return signaling NaN value.input
is NaN, return NaN value.input
is infinity (positive or negative), then return infinity with the same sign.input
is zero (positive or negative), then return zero with the same sign.input
has an absolute value that is larger than maximum or is smaller than minimum value supported by the result type, store the value of the macro ERANGE
into errno
and return infinity or zero with the same sign respectively.input
has a value that is not exactly representable using maximum digit number supported by the indicated result type then return the input
rounded according to the rounding direction.input
value of the result type.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Examples: copysign( 5.0, -2.0)
==> -5.0; copysign(-5.0, -2.0)
==> -5.0
|
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.
|
inlinestatic |
|
static |
|
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
).
|
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:
value
is NaN, return FP_NAN;value
is infinity, return FP_INFINITE
;value
is a subnormal value, return FP_SUBNORMAL
;value
is a zero value, return FP_ZERO
;FP_NORMAL
.
|
static |
Return the smallest positive denormalized value for the ValueType128
type (IEEE-754: +0.000000000000000000000000000000001e-6143).
|
static |
Return the smallest positive denormalized value for the ValueType32
type (IEEE-754: +0.000001e-95).
|
static |
Return the smallest positive denormalized value for the ValueType64
type (IEEE-754: +0.000000000000001e-383).
|
inlinestatic |
lhs
or rhs
is signaling NaN, then store the value of the macro EDOM
into errno
and return a NaN.lhs
or rhs
is NaN, return a NaN.lhs
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.lhs
has a normal value and rhs
has a positive zero value, store the value of the macro ERANGE
into errno
and return infinity with the sign of lhs
.lhs
has a normal value and rhs
has a negative zero value, store the value of the macro ERANGE
into errno
and return infinity with the opposite sign as lhs
.lhs
by the value of rhs
results in an absolute value that is larger than the maximum value supported by the result type then store the value of the macro ERANGE
into errno
and return infinity with the same sign as that result.lhs
by the value of rhs
results in an absolute value that is smaller than min value supported by the indicated result type then store the value of the macro ERANGE
into errno
and return zero with the same sign as that result.lhs
by the value of rhs
.
|
inlinestatic |
Divide the value of the specified lhs
by the value of the specified rhs
as described by IEEE-754, and return the result.
|
inlinestatic |
|
static |
Return the difference between the least representable value of type ValueType128
greater than 1 and 1 (IEEE-754: +1e-33).
|
static |
Return the difference between the least representable value of type ValueType32
greater than 1 and 1 (IEEE-754: +1e-6).
|
static |
Return the difference between the least representable value of type ValueType64
greater than 1 and 1 (IEEE-754: +1e-15).
|
inlinestatic |
If either or both operands are signaling NaN, store the value of the macro EDOM
into errno
and return false
.
|
inlinestatic |
Return true
if the specified lhs
and rhs
have the same value, and false
otherwise. Two decimal objects have the same value if the compareQuietEqual
operation (IEEE-754 defined, non-total ordering comparison) considers the underlying IEEE representations equal. In other words, two decimal objects have the same value if:
|
inlinestatic |
|
inlinestatic |
Special value handling:
x
is +/-0, 1 is returned.x
is negative infinity, +0 is returned.x
is +infinity, +infinity is returned.x
is quiet NaN, quiet NaN is returned.x
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.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.
|
inlinestatic |
Return e
(Euler's number, 2.7182818) raised to the specified power x
.
|
inlinestatic |
|
inlinestatic |
Special value handling:
x
is NaN (either signaling or quiet), quiet NaN is returned.x
is +/-infinity or +/-0, it is returned unmodified.
|
inlinestatic |
Return the absolute value of the specified x
.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return the largest integral value that is not greater than the specified x
.
Special value handling:
x
is quiet NaN, quiet NaN is returned.x
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +/-infinity or +/-0, it is returned unmodified.
|
inlinestatic |
|
inlinestatic |
Special value handling:
x
or y
are quiet NaN, quiet NaN is returned.EDOM
is stored into errno
.x*y
is an exact infinity and z
is infinity with the opposite sign, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.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
.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.
|
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.
|
inlinestatic |
|
inlinestatic |
Special value handling:
EDOM
is stored into errno
.x
is +/-infnity and y
is not NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +/-0 and y
is not zero, +/-0 is returned.y
is +/-0, quite NaN is returned and the value of the macro EDOM
is stored into errno
.x
is finite and y
is +/-infnity, x
is returned.
|
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.
|
inlinestatic |
|
static |
Format the specified value
, according to the parameters in the specified cfg
. Place 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. See the Attributes section under @DESCRIPTION in the component-level documentation for bdldfp::DecimalFormatConfig
component 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.
|
static |
|
static |
|
inlinestatic |
If either or both operands are signaling NaN, store the value of the macro EDOM
into errno
and return false
.
|
inlinestatic |
Return true
if the specified lhs
has a greater value than the specified rhs
and false
otherwise. The value of a Decimal64
object lhs
is greater than that of an object rhs
if the compareQuietGreater
operation (IEEE-754 defined, non-total ordering comparison) considers the underlying IEEE representation of lhs
to be greater than of that of rhs
. In other words, lhs
is greater than rhs
if:
lhs
nor rhs
are NaN, orrhs
is zero (positive or negative) and lhs
positive, orlhs
is zero (positive or negative) and rhs
negative, orlhs
is not negative infinity, orlhs
is positive infinity and rhs
is not, orlhs
and rhs
both represent a real number and the real number of lhs
is greater than that of rhs
|
inlinestatic |
|
inlinestatic |
If either or both operands are signaling NaN, store the value of the macro EDOM
into errno
and return false
.
|
inlinestatic |
Return true
if the specified lhs
has a value greater than or equal to the value of the specified rhs
and false
otherwise. The value of a Decimal64
object lhs
is greater or equal to a Decimal64
object rhs
if the compareQuietGreaterEqual
operation (IEEE-754 defined, non-total ordering comparison ) considers the underlying IEEE representation of lhs
to be greater or equal to that of rhs
. In other words, lhs
is greater than or equal to rhs
if:
lhs
nor rhs
are NaN, orlhs
and rhs
are both zero (positive or negative), orlhs
and rhs
are negative infinity, orlhs
is positive infinity, orlhs
and rhs
both represent a real number and the real number of lhs
is greater or equal to that of rhs
|
inlinestatic |
|
static |
Return the value that represents positive infinity for the ValueType128
type.
|
static |
Return the value that represents positive infinity for the ValueType32
type.
|
static |
Return the value that represents positive infinity for the ValueType64
type.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
The exponent 0 (quantum 1e-15) is preferred during conversion unless it would cause unnecessary loss of precision.
|
inlinestatic |
|
inlinestatic |
The exponent 0 (quantum 1e-6) is preferred during conversion unless it would cause unnecessary loss of precision.
|
inlinestatic |
If either or both operands are signaling NaN, store the value of the macro EDOM
into errno
and return false
.
|
inlinestatic |
Return true
if the specified lhs
has a value less than the specified rhs
and false
otherwise. The value of a Decimal64
object lhs
is less than that of an object rhs
if the compareQuietLess
operation (IEEE-754 defined, non-total ordering comparison) considers the underlying IEEE representation of lhs
to be less than of that of rhs
. In other words, lhs
is less than rhs
if:
lhs
nor rhs
are NaN, orlhs
is zero (positive or negative) and rhs
is positive, orrhs
is zero (positive or negative) and lhs
negative, orlhs
is not positive infinity, orlhs
is negative infinity and rhs
is not, orlhs
and rhs
both represent a real number and the real number of lhs
is less than that of rhs
|
inlinestatic |
|
inlinestatic |
If either or both operands are signaling NaN, store the value of the macro EDOM
into errno
and return false
.
|
inlinestatic |
Return true
if the specified lhs
has a value less than or equal the value of the specified rhs
and false
otherwise. The value of a Decimal64
object lhs
is less than or equal to the value of an object rhs
if the compareQuietLessEqual
operation (IEEE-754 defined, non-total ordering comparison) considers the underlying IEEE representation of lhs
to be less or equal to that of rhs
. In other words, lhs
is less or equal than rhs
if:
lhs
nor rhs
are NaN, orlhs
and rhs
are both zero (positive or negative), orlhs
and rhs
are positive infinity, orlhs
is negative infinity, orlhs
and rhs
both represent a real number and the real number of lhs
is less or equal to that of rhs
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Special value handling:
x
is +/-0, -infinity is returned and the value of the macro ERANGE
is stored into errno
.x
is 1, +0 is returned.x
is negative, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +infinity, +infinity is returned.x
is quiet NaN, quiet NaN is returned.x
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.
|
inlinestatic |
Return the natural (base e
) logarithm of the specified x
.
|
inlinestatic |
|
inlinestatic |
Special value handling:
x
is +/-0, -infinity is returned and the value of the macro ERANGE
is stored into errno
.x
is 1, +0 is returned.x
is negative, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +infinity, +infinity is returned.x
is quiet NaN, quiet NaN is returned.x
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.
|
inlinestatic |
Return the common (base-10) logarithm of the specified x
.
|
inlinestatic |
|
inlinestatic |
Examples: logB( 10.0)
==> 1.0; logB(-100.0)
==> 2.0
|
inlinestatic |
Return the FLT_RADIX-based logarithm (i.e., base 10) of the absolute value of the specified x
.
Special value handling:
x
is +/-0, -infinity is returned and the value of the macro ERANGE
is stored into errno
.x
is 1, +0 is returned.x
is +/-infinity, +infinity is returned.x
is quiet NaN, quiet NaN is returned.x
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.
|
inlinestatic |
|
inlinestatic |
Special value handling:
EDOM
is stored into errno
.y
is +/-0, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +/-infnity and y
is not NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is finite and y
is +/-infnity, x
is returned.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
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:
x
is NaN (either quiet or signaling), quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +/-infinity, quite NaN is returned and the value of the macro EDOM
is stored into errno
.EDOM
is stored into errno
.
|
inlinestatic |
|
static |
|
static |
|
static |
|
static |
Return a Decimal64
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.
|
inlinestatic |
Create a ValueType128
object representing a decimal floating point number consisting of the specified significand
and exponent
, with the sign given by significand
. The behavior is undefined unless -6176 <= exponent <= 6111
.
|
static |
|
inlinestatic |
|
static |
|
inlinestatic |
Create a ValueType32
object representing a decimal floating point number consisting of the specified significand
and exponent
, with the sign given by significand
. The behavior is undefined unless abs(significand) <= 9,999,999
and -101 <= exponent <= 90
.
|
inlinestatic |
Create a ValueType64
object representing a decimal floating point number consisting of the specified significand
and exponent
, with the sign given by significand
. The behavior is undefined unless abs(significand) <= 9,999,999,999,999,999
and -398 <= exponent <= 369
.
|
static |
|
inlinestatic |
|
static |
|
static |
Return a ValueType64
representing infinity. Optionally specify whether the infinity isNegative
. If isNegative
is false
or is is not supplied, the returned value will be infinity, and negative infinity otherwise.
|
static |
Return the largest number ValueType128
can represent (IEEE-754: +9.999999999999999999999999999999999e+6144).
|
static |
Return the largest number ValueType32
can represent (IEEE-754: +9.999999e+96).
|
static |
Return the largest number ValueType64
can represent (IEEE-754: +9.999999999999999e+384).
|
static |
Return the smallest positive normalized number ValueType128
can represent (IEEE-754: +1e-6143).
|
static |
Return the smallest positive normalized number ValueType32
can represent (IEEE-754: +1e-95).
|
static |
Return the smallest positive normalized number ValueType64
can represent (IEEE-754: +1e-383).
|
inlinestatic |
lhs
or rhs
is signaling NaN, then store the value of the macro EDOM
into errno
and return a NaN.lhs
or rhs
is NaN, return a NaN.EDOM
into errno
and return a NaN.lhs
and rhs
are infinity (positive or negative), return infinity. The sign of the returned value will be positive if lhs
and rhs
have the same sign, and negative otherwise.lhs
or rhs
is zero, return zero. The sign of the returned value will be positive if lhs
and rhs
have the same sign, and negative otherwise.lhs
and rhs
has an absolute value that is larger than the maximum value of the indicated result type then store the value of the macro ERANGE
into errno
and return infinity with the same sign as that result.lhs
and rhs
has an absolute value that is smaller than min value of the indicated result type then store the value of the macro ERANGE
into errno
and return zero with the same sign as that result.rhs
and the number represented by rhs
.
|
inlinestatic |
Multiply the value of the specified lhs
object by the value of the specified rhs
as described by IEEE-754 and return the result.
|
inlinestatic |
|
inlinestatic |
Return the result of applying the unary negation (-
) operator to the specified value
as described by IEEE-754. Note that decimal floating point representations can encode signed zero values, thus negating 0 results in -0 and negating -0 results in 0.
|
inlinestatic |
|
inlinestatic |
|
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.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Special value handling:
from
equals to
, to
is returned.EDOM
is stored into errno
.from
is finite, but the expected result is infinity, infinity is returned and the value of the macro ERANGE
is stored into errno
.from
does not equal to
and the result is subnormal or zero, the value of the macro ERANGE
is stored into errno
.
|
inlinestatic |
Return the next representable value of the specified from
in the direction of the specified to
.
|
inlinestatic |
|
static |
|
static |
Return a ValueTypeXX
number having the value as the specified 'original, but with the significand, that can not be divided by ten, and appropriate exponent.
|
static |
|
inlinestatic |
If either or both operands are signaling NaN, store the value of the macro EDOM
into errno
and return false
.
|
inlinestatic |
Return false
if the specified lhs
and rhs
have the same value, and true
otherwise. Two decimal objects have the same value if the compareQuietEqual
operation (IEEE-754 defined, non-total ordering comparison) considers the underlying IEEE representations equal. In other words, two decimal objects have the same value if:
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Produce an object of the indicated return type by parsing the specified input
string that represents a floating-point number (written in either fixed or scientific notation). Optionally specify status
in which to load a bit mask of additional status information. The resulting decimal object is initialized as follows:
input
does not represent a floating-point value, then return a decimal object of the indicated return type initialized to a NaN.input
represents infinity (positive or negative), as case-insensitive "Inf" or "Infinity" string, then return a decimal object of the indicated return type initialized to infinity value with the same sign.input
represents zero (positive or negative), then return a decimal object of the indicated return type initialized to zero with the same sign.str
represents a value that has an absolute value that is larger than std::numeric_limits<Decimal32>::max()
then store the value of the macro ERANGE
into errno
and return a decimal object of the indicated return type initialized to infinity with the same sign.input
represents a value that has an absolute value that is smaller than std::numeric_limits<Decimal32>::min()
, then store the value of the macro ERANGE
into errno
and return a decimal object of the indicated return type initialized to zero with the same sign.input
has a value that is not exactly representable using std::numeric_limits<Decimal32>::max_digit
decimal digits then return a decimal object of the indicated return type initialized to the value represented by input
rounded according to the rounding direction.input
.The *status
, if supplied, mest be 0, and may be loaded with a bit mask of k_STATUS_INEXACT
, k_STATUS_UNDERFLOW
, and k_STATUS_OVERFLOW
indicating wether the conversion from text was inexact, underflowed, or overflowed (or some combination) respectively. The behavior is undefined unless *status
(if supplied) is 0.
Note that the parsing follows the rules as specified for the strtod32
function in section 9.6 of the ISO/EIC TR 24732 C Decimal Floating-Point Technical Report.
Also note that the quanta of the resultant value is determined by the number of decimal places starting with the most significand digit in input
string and cannot exceed the maximum number of digits necessary to differentiate all values of the indicated return type, for example:
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Special value handling:
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
.ERANGE
is stored into errno
.ERANGE
is stored into errno
.EDOM
is stored into errno
.
|
inlinestatic |
Return the value of the specified base
raised to the power of the specified exp
.
|
inlinestatic |
|
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
Decimal32
type: -101 <= exponent <= 90
Decimal64
type: -398 <= exponent <= 369
Decimal128
type: -6176 <= exponent <= 6111
|
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
.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
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);
|
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
Decimal32
type: -101 <= exponent <= 90
Decimal64
type: -398 <= exponent <= 369
Decimal128
type: -6176 <= exponent <= 6111
|
inlinestatic |
|
static |
Return a value that represents non-signaling NaN for the ValueType128
type.
|
static |
Return a value that represents non-signaling NaN for the ValueType32
type.
|
static |
Return a value that represents non-signaling NaN for the ValueType64
type.
|
inlinestatic |
|
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
.
|
inlinestatic |
|
inlinestatic |
|
static |
|
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:
x
is quiet NaN, quiet NaN is returned.x
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +/-infinity or +/-0, it is returned unmodified.
|
static |
Return the specified x
value rounded to the specified precision
. 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.
|
inlinestatic |
|
static |
|
static |
Return the maximum rounding error for the ValueType128
type. The actual value returned depends on the current decimal floating point rounding setting.
|
static |
Return the maximum rounding error for the ValueType32
type. The actual value returned depends on the current decimal floating point rounding setting.
|
static |
Return the maximum rounding error for the ValueType64
type. The actual value returned depends on the current decimal floating point rounding setting.
|
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.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Special value handling:
value
is quiet NaN, quiet NaN is returned.value
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is infinite, then infinity is returned.ERANGE
is stored into errno
.
|
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.
|
inlinestatic |
|
static |
Return a value that represents signaling NaN for the ValueType128
type.
|
static |
Return a value that represents signaling NaN for the ValueType32
type.
|
static |
Return a value that represents signaling NaN for the ValueType64
type.
|
inlinestatic |
Special value handling:
x
is quiet NaN, quiet NaN is returned.x
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is less than -0, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +/-infinity or +/-0, it is returned unmodified.
|
inlinestatic |
Return the square root of the specified x
.
|
inlinestatic |
|
inlinestatic |
lhs
or rhs
is signaling NaN, then store the value of the macro EDOM
into errno
and return a NaN.lhs
or rhs
is NaN, return a NaN.lhs
and the rhs
have infinity values of the same sign, store the value of the macro EDOM
into errno
and return a NaN.lhs
and the rhs
have infinity values of differing signs, then return lhs
.rhs
has a zero value (positive or negative), then return lhs
.lhs
and rhs
has an absolute value that is larger than the maximum value supported by the indicated result type then store the value of the macro ERANGE
into errno
and return infinity with the same sign as that result.rhs
from the value of lhs
.
|
inlinestatic |
Subtract the value of the specified rhs
from the value of the specified lhs
as described by IEEE-754 and return the result.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return the nearest integral value that is not greater in absolute value than the specified x
.
Special value handling:
x
is quiet NaN, quiet NaN is returned.x
is signaling NaN, quiet NaN is returned and the value of the macro EDOM
is stored into errno
.x
is +/-infinity or +/-0, it is returned unmodified.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return a Decimal128
object having the value closest to the specified value
subject to the conversion rules as defined by IEEE-754:
value
is zero then initialize this object to a zero with an unspecified sign and an unspecified exponent.value
has a value that is not exactly representable using std::numeric_limits<Decimal128>::max_digit
decimal digits then return a decimal value initialized to the value of value
rounded according to the rounding direction.value
.The exponent 0 (quantum 1e-33) is preferred during conversion unless it would cause unnecessary loss of precision.
|
inlinestatic |
Return a Decimal32
object having the value closest to the specified value
following the conversion rules as defined by IEEE-754:
value
is zero then initialize this object to a zero with an unspecified sign and an unspecified exponent.value
has a value that is not exactly representable using std::numeric_limits<Decimal32>::max_digit
decimal digits then return a decimal value initialized to the value of value
rounded according to the rounding direction.value
.
|
inlinestatic |
Return a Decimal64
object having the value closest to the specified value
following the conversion rules as defined by IEEE-754:
value
is zero then initialize this object to a zero with an unspecified sign and an unspecified exponent.value
has a value that is not exactly representable using std::numeric_limits<Decimal64>::max_digit
decimal digits then return a decimal value initialized to the value of value
rounded according to the rounding direction.value
.