|
BDE 4.14.0 Production release
|
#include <bdldfp_decimalconvertutil.h>
Static Public Member Functions | |
| static double | decimal32ToDouble (Decimal32 decimal) |
| static double | decimal64ToDouble (Decimal64 decimal) |
| static double | decimal128ToDouble (Decimal128 decimal) |
[DEPRECATED] Use deciamalToDouble instead. | |
| static double | decimalToDouble (Decimal32 decimal) |
| static double | decimalToDouble (Decimal64 decimal) |
| static double | decimalToDouble (Decimal128 decimal) |
| static float | decimal32ToFloat (Decimal32 decimal) |
| static float | decimal64ToFloat (Decimal64 decimal) |
| static float | decimal128ToFloat (Decimal128 decimal) |
[DEPRECATED] Use deciamalToFloat instead. | |
| static float | decimalToFloat (Decimal32 decimal) |
| static float | decimalToFloat (Decimal64 decimal) |
| static float | decimalToFloat (Decimal128 decimal) |
| static Decimal32 | decimal32FromDouble (double binary, int digits=0) |
| static Decimal32 | decimal32FromFloat (float binary, int digits=0) |
| static Decimal64 | decimal64FromDouble (double binary, int digits=0) |
| static Decimal64 | decimal64FromFloat (float binary, int digits=0) |
| static Decimal128 | decimal128FromDouble (double binary, int digits=0) |
| static Decimal128 | decimal128FromFloat (float binary, int digits=0) |
| static void | decimal32ToDPD (unsigned char *buffer, Decimal32 decimal) |
| static void | decimal64ToDPD (unsigned char *buffer, Decimal64 decimal) |
| static void | decimal128ToDPD (unsigned char *buffer, Decimal128 decimal) |
| static void | decimalToDPD (unsigned char *buffer, Decimal32 decimal) |
| static void | decimalToDPD (unsigned char *buffer, Decimal64 decimal) |
| static void | decimalToDPD (unsigned char *buffer, Decimal128 decimal) |
| static Decimal32 | decimal32FromDPD (const unsigned char *buffer) |
| static Decimal64 | decimal64FromDPD (const unsigned char *buffer) |
| static Decimal128 | decimal128FromDPD (const unsigned char *buffer) |
| static void | decimal32FromDPD (Decimal32 *decimal, const unsigned char *buffer) |
| static void | decimal64FromDPD (Decimal64 *decimal, const unsigned char *buffer) |
| static void | decimal128FromDPD (Decimal128 *decimal, const unsigned char *buffer) |
| static void | decimalFromDPD (Decimal32 *decimal, const unsigned char *buffer) |
| static void | decimalFromDPD (Decimal64 *decimal, const unsigned char *buffer) |
| static void | decimalFromDPD (Decimal128 *decimal, const unsigned char *buffer) |
| static void | decimal32ToBID (unsigned char *buffer, Decimal32 decimal) |
| static void | decimal64ToBID (unsigned char *buffer, Decimal64 decimal) |
| static void | decimal128ToBID (unsigned char *buffer, Decimal128 decimal) |
| static void | decimalToBID (unsigned char *buffer, Decimal32 decimal) |
| static void | decimalToBID (unsigned char *buffer, Decimal64 decimal) |
| static void | decimalToBID (unsigned char *buffer, Decimal128 decimal) |
| static Decimal32 | decimal32FromBID (const unsigned char *buffer) |
| static Decimal64 | decimal64FromBID (const unsigned char *buffer) |
| static Decimal128 | decimal128FromBID (const unsigned char *buffer) |
| static void | decimal32FromBID (Decimal32 *decimal, const unsigned char *buffer) |
| static void | decimal64FromBID (Decimal64 *decimal, const unsigned char *buffer) |
| static void | decimal128FromBID (Decimal128 *decimal, const unsigned char *buffer) |
| static void | decimalFromBID (Decimal32 *decimal, const unsigned char *buffer) |
| static void | decimalFromBID (Decimal64 *decimal, const unsigned char *buffer) |
| static void | decimalFromBID (Decimal128 *decimal, const unsigned char *buffer) |
| static unsigned char * | decimal32ToNetwork (unsigned char *buffer, Decimal32 decimal) |
| static unsigned char * | decimal64ToNetwork (unsigned char *buffer, Decimal64 decimal) |
| static unsigned char * | decimal128ToNetwork (unsigned char *buffer, Decimal128 decimal) |
| static unsigned char * | decimalToNetwork (unsigned char *buffer, Decimal32 decimal) |
| static unsigned char * | decimalToNetwork (unsigned char *buffer, Decimal64 decimal) |
| static unsigned char * | decimalToNetwork (unsigned char *buffer, Decimal128 decimal) |
| static const unsigned char * | decimal32FromNetwork (Decimal32 *decimal, const unsigned char *buffer) |
| static const unsigned char * | decimal64FromNetwork (Decimal64 *decimal, const unsigned char *buffer) |
| static const unsigned char * | decimal128FromNetwork (Decimal128 *decimal, const unsigned char *buffer) |
| static const unsigned char * | decimalFromNetwork (Decimal32 *decimal, const unsigned char *buffer) |
| static const unsigned char * | decimalFromNetwork (Decimal64 *decimal, const unsigned char *buffer) |
| static const unsigned char * | decimalFromNetwork (Decimal128 *decimal, const unsigned char *buffer) |
| static bsls::Types::size_type | decimal64ToMultiWidthEncoding (unsigned char *buffer, bdldfp::Decimal64 decimal) |
| static bsls::Types::size_type | decimal64ToMultiWidthEncodingRaw (unsigned char *buffer, bdldfp::Decimal64 decimal) |
| static Decimal64 | decimal64FromMultiWidthEncodingRaw (const unsigned char *buffer, bsls::Types::size_type size) |
| static bool | isValidMultiWidthSize (bsls::Types::size_type size) |
| static Decimal64 | decimal64FromMultiWidthEncoding (const unsigned char *buffer, bsls::Types::size_type size) |
| static int | decimal64FromMultiWidthEncodingIfValid (Decimal64 *decimal, const unsigned char *buffer, bsls::Types::size_type size) |
| static unsigned char * | decimal64ToVariableWidthEncoding (unsigned char *buffer, bdldfp::Decimal64 decimal) |
| static const unsigned char * | decimal64FromVariableWidthEncoding (bdldfp::Decimal64 *decimal, const unsigned char *buffer) |
This struct provides a namespace for utility functions that convert between the decimal floating-point types of bdldfp_decimal and various other formats.
|
inlinestatic |
|
inlinestatic |
Return the native implementation representation of the value of the same size base-10 floating-point value stored in Binary Integer Decimal format at the specified buffer address. The behavior is undefined unless buffer points to a memory area at least sizeof(decimal) in size containing a value in BID format.
|
static |
|
inlinestatic |
|
inlinestatic |
Return the native implementation representation of the value of the same size base-10 floating-point value stored in Densely Packed Decimal format at the specified buffer address. The behavior is undefined unless buffer points to a memory area at least sizeof(decimal) in size containing a value in DPD format.
|
static |
Return a decimal floating-point number converted from the specified binary.
If binary is singular (+/-NaN, +/-Inf, or +/-0) or is not within the representable range of the return type, return a corresponding decimal singular value.
Optionally specify digits to indicate the number of significant digits to produce in the returned value. The digits parameter is treated as follows:
If digits is larger than the number of digits in the destination type, it will be reduced to that number of digits.
If digits is positive, the result is binary rounded to that many significant digits.
If digits is negative, the decimal value with the fewest significant digits that converts back to binary is returned if possible, and otherwise the value closest to binary is returned. Note that this provides the most visually appealing result but is the most expensive to compute.
If digits is not specified or 0, a default value will be used (possibly depending on the value of binary) based on the premise that binary is a converted decimal value of no more significant digits than is guaranteed to have a uniquely converted binary value (15 for double, 6 for float in general, and 7 for float in the range [ .0009999995 .. 8589972000 ]). Note that this is likely to have the best performance for "business" numbers (i.e., numbers that originate as decimal values in external market quote feeds).
Note that the purpose of these functions is to restore a decimal value that has been converted to a binary floating-point type. It is more efficient to use conversion constructors when all that is needed is the nearest decimal to the binary value.
Note that if binary is a float value that was converted from an IBM/Perkin-Elmer/Interdata binary float value itself converted from a decimal value of no more than 6 significant digits, specifying 6 for digits will recover the original decimal value. Not specifying digits may result in a value having a spurious seventh digit.
|
static |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
|
inlinestatic |
|
inlinestatic |
|
static |
|
inlinestatic |
|
inlinestatic |
|
static |
|
static |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
|
inlinestatic |
|
inlinestatic |
|
static |
|
inlinestatic |
|
inlinestatic |
|
static |
|
inlinestatic |
Decode a decimal value in the multi-width encoding format from the specified buffer having the specified size. Return the decoded value. The behavior is undefined unless buffer has at least size bytes, and size is a valid encoding size in the multi-width encoding format.
|
inlinestatic |
Decode a decimal value in the multi-width encoding format from the specified buffer having the specified size and store the result into the specified decimal parameter. Return 0 on success, and non-zero value otherwise. The behavior is undefined unless buffer has at least size bytes. Note that this function returns a non-zero value and leaves decimal unchanged if size is not a valid encoding size of the multi-width encoding format.
|
inlinestatic |
Decode a decimal value in the multi-width encoding format from the specified buffer having the specified size. Return the decoded value. The behavior is undefined unless buffer has at least size bytes, size is a valid encoding size in the multi-width encoding format, and size <= 5. Note that this function does not support decoding values requiring a full IEEE network encoding, which is supported by the decimal64FromMultiWidthEncoding function.
|
static |
|
inlinestatic |
Store into the specified decimal, the value of Decimal64 value stored in the variable-width encoding format at the specified buffer address. Return the address one past the last byte read from buffer. The behavior is undefined unless buffer points to a memory area holding a Decimal64 value encoded in the variable-width encoding format.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Store the specified decimal, in the multi-width encoding format, into the specified buffer and return the number of bytes used by the encoding. The behavior is undefined unless buffer points to a memory area with enough room to hold the encode value (which has a maximum size of 8 bytes).
|
inlinestatic |
If the specified decimal can be encoded in 5 or fewer bytes of the multi-width encoding format, then store decimal into the specified buffer in that format, and return the number of bytes written to buffer. Otherwise, return 0. The behavior is undefined unless buffer points to a memory area having at least 5 bytes. Note that this function does not supporting encoding values requiring a full IEEE network encoding, which is supported by the decimal64ToMultiWidthEncoding function.
|
static |
|
inlinestatic |
Store the specified decimal, in the variable-width encoding format, into the specified buffer and return the address one past the last byte written into the buffer. The behavior is undefined unless buffer points to a memory area with enough room to hold the encoded value (which has a maximum size of 9 bytes).
|
inlinestatic |
Store, into the specified decimal, the native implementation representation of the value of the same size base-10 floating point value represented in Binary Integer Decimal format, at the specified buffer address. The behavior is undefined unless buffer points to a memory area at least sizeof(decimal) in size containing a value in BID format.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Store, into the specified decimal, the native implementation representation of the value of the same size base-10 floating point value represented in Densely Packed Decimal format, at the specified buffer address. The behavior is undefined unless buffer points to a memory area at least sizeof(decimal) in size containing a value in DPD format.
|
inlinestatic |
|
inlinestatic |
|
static |
|
static |
Store into the specified decimal, the value of the same size base-10 floating-point value stored in network format at the specified buffer address and return the address one past the last byte read from buffer. The network format is defined as big endian byte order and densely packed base-10 significand encoding. This corresponds to the way IBM hardware represents these numbers in memory. The behavior is undefined unless buffer points to a memory area at least sizeof(decimal) bytes. Note that these functions always return buffer + sizeof(decimal) on the supported 8-bits-byte architectures.
|
static |
|
inlinestatic |
Populate the specified buffer with the Binary Integer Decimal (BID) representation of the specified decimal value. The BID representations of Decimal32, Decimal64, and Decimal128 require 4, 8, and 16 bytes respectively. The behavior is undefined unless buffer points to a contiguous sequence of at least sizeof(decimal) bytes. Note that the BID representation is defined in section 3.5 of IEEE 754-2008.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
decimal object is a NaN, return a NaN.decimal is positive or negative infinity, return infinity of the same sign.decimal is positive or negative zero, return zero of the same sign.decimal object has an absolute value that is larger than std::numeric_limits<double>::max(), raise the "overflow" floating-point exception and return infinity of the same sign as decimal.decimal has an absolute value that is smaller than std::numeric_limits<double>::min(), raise the "underflow" floating-point exception and return zero of the same sign as decimal.decimal has a value that has more significant base-10 digits than std::numeric_limits<double>::digits10, raise the "inexact" floating-point exception, round that value according to the binary rounding direction setting of the floating-point environment, and return the result of that.decimal has a significand that cannot be exactly represented using binary floating-point, raise the "inexact" floating-point exception, round that value according to the binary rounding direction setting of the environment, and return the result of that.other object for the initialization if this object.
|
inlinestatic |
Return a double object having the value closest to the value of the specified decimal object following the conversion rules defined by IEEE-754:
|
inlinestatic |
|
inlinestatic |
Populate the specified buffer with the Densely Packed Decimal (DPD) representation of the specified decimal value. The DPD representations of Decimal32, Decimal64, and Decimal128 require 4, 8, and 16 bytes respectively. The behavior is undefined unless buffer points to a contiguous sequence of at least sizeof(decimal) bytes. Note that the DPD representation is defined in section 3.5 of IEEE 754-2008.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
decimal object is a NaN, return a NaN.decimal is positive or negative infinity, return infinity of the same sign.decimal is positive or negative zero, return zero of the same sign.decimal object has an absolute value that is larger than std::numeric_limits<long double>::max(), raise the "overflow" floating-point exception and return infinity of the same sign as decimal.decimal has an absolute value that is smaller than std::numeric_limits<float>::min(), raise the "underflow" floating-point exception and return zero of the same sign as decimal.decimal has a value that has more significant base-10 digits than std::numeric_limits<float>::digits10, raise the "inexact" floating-point exception, round that value according to the binary rounding direction setting of the floating-point environment, and return the result of that.decimal has a significand that cannot be exactly represented using binary floating-point, raise the "inexact" floating-point exception, round that value according to the binary rounding direction setting of the environment, and return the result of that.other object for the initialization if this object.
|
inlinestatic |
Return a float object having the value closest to the value of the specified decimal object following the conversion rules defined by IEEE-754:
|
inlinestatic |
|
static |
|
static |
Store the specified decimal, in network format, into the specified buffer and return the address one past the last byte written into the buffer. The network format is defined as big endian byte order and densely packed base-10 significand encoding. This corresponds to the way IBM hardware represents these numbers in memory. The behavior is undefined unless buffer points to a memory area at least sizeof(decimal) in size. Note that these functions always return buffer + sizeof(decimal) on the supported 8-bits-byte architectures.
|
static |
|
inlinestatic |
Return true if the specified size is a valid encoding size in the multi-width encoding format, and false otherwise. Note that valid encoding sizes are 1, 2, 3, 4, 5 and 8 bytes.