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

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

Detailed Description

This struct provides a namespace for utility functions that convert between the decimal floating-point types of bdldfp_decimal and various other formats.

Member Function Documentation

◆ decimal128FromBID() [1/2]

Decimal128 bdldfp::DecimalConvertUtil::decimal128FromBID ( const unsigned char *  buffer)
inlinestatic

◆ decimal128FromBID() [2/2]

void bdldfp::DecimalConvertUtil::decimal128FromBID ( Decimal128 decimal,
const unsigned char *  buffer 
)
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.

◆ decimal128FromDouble()

static Decimal128 bdldfp::DecimalConvertUtil::decimal128FromDouble ( double  binary,
int  digits = 0 
)
static

◆ decimal128FromDPD() [1/2]

Decimal128 bdldfp::DecimalConvertUtil::decimal128FromDPD ( const unsigned char *  buffer)
inlinestatic

◆ decimal128FromDPD() [2/2]

void bdldfp::DecimalConvertUtil::decimal128FromDPD ( Decimal128 decimal,
const unsigned char *  buffer 
)
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.

◆ decimal128FromFloat()

static Decimal128 bdldfp::DecimalConvertUtil::decimal128FromFloat ( float  binary,
int  digits = 0 
)
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.

◆ decimal128FromNetwork()

static const unsigned char * bdldfp::DecimalConvertUtil::decimal128FromNetwork ( Decimal128 decimal,
const unsigned char *  buffer 
)
static

◆ decimal128ToBID()

void bdldfp::DecimalConvertUtil::decimal128ToBID ( unsigned char *  buffer,
Decimal128  decimal 
)
inlinestatic

◆ decimal128ToDouble()

double bdldfp::DecimalConvertUtil::decimal128ToDouble ( Decimal128  decimal)
inlinestatic

◆ decimal128ToDPD()

void bdldfp::DecimalConvertUtil::decimal128ToDPD ( unsigned char *  buffer,
Decimal128  decimal 
)
inlinestatic

◆ decimal128ToFloat()

float bdldfp::DecimalConvertUtil::decimal128ToFloat ( Decimal128  decimal)
inlinestatic

◆ decimal128ToNetwork()

static unsigned char * bdldfp::DecimalConvertUtil::decimal128ToNetwork ( unsigned char *  buffer,
Decimal128  decimal 
)
static

◆ decimal32FromBID() [1/2]

Decimal32 bdldfp::DecimalConvertUtil::decimal32FromBID ( const unsigned char *  buffer)
inlinestatic

◆ decimal32FromBID() [2/2]

void bdldfp::DecimalConvertUtil::decimal32FromBID ( Decimal32 decimal,
const unsigned char *  buffer 
)
inlinestatic

◆ decimal32FromDouble()

static Decimal32 bdldfp::DecimalConvertUtil::decimal32FromDouble ( double  binary,
int  digits = 0 
)
static

◆ decimal32FromDPD() [1/2]

Decimal32 bdldfp::DecimalConvertUtil::decimal32FromDPD ( const unsigned char *  buffer)
inlinestatic

◆ decimal32FromDPD() [2/2]

void bdldfp::DecimalConvertUtil::decimal32FromDPD ( Decimal32 decimal,
const unsigned char *  buffer 
)
inlinestatic

◆ decimal32FromFloat()

static Decimal32 bdldfp::DecimalConvertUtil::decimal32FromFloat ( float  binary,
int  digits = 0 
)
static

◆ decimal32FromNetwork()

static const unsigned char * bdldfp::DecimalConvertUtil::decimal32FromNetwork ( Decimal32 decimal,
const unsigned char *  buffer 
)
static

◆ decimal32ToBID()

void bdldfp::DecimalConvertUtil::decimal32ToBID ( unsigned char *  buffer,
Decimal32  decimal 
)
inlinestatic

◆ decimal32ToDouble()

double bdldfp::DecimalConvertUtil::decimal32ToDouble ( Decimal32  decimal)
inlinestatic

◆ decimal32ToDPD()

void bdldfp::DecimalConvertUtil::decimal32ToDPD ( unsigned char *  buffer,
Decimal32  decimal 
)
inlinestatic

◆ decimal32ToFloat()

float bdldfp::DecimalConvertUtil::decimal32ToFloat ( Decimal32  decimal)
inlinestatic

◆ decimal32ToNetwork()

static unsigned char * bdldfp::DecimalConvertUtil::decimal32ToNetwork ( unsigned char *  buffer,
Decimal32  decimal 
)
static

◆ decimal64FromBID() [1/2]

Decimal64 bdldfp::DecimalConvertUtil::decimal64FromBID ( const unsigned char *  buffer)
inlinestatic

◆ decimal64FromBID() [2/2]

void bdldfp::DecimalConvertUtil::decimal64FromBID ( Decimal64 decimal,
const unsigned char *  buffer 
)
inlinestatic

◆ decimal64FromDouble()

static Decimal64 bdldfp::DecimalConvertUtil::decimal64FromDouble ( double  binary,
int  digits = 0 
)
static

◆ decimal64FromDPD() [1/2]

Decimal64 bdldfp::DecimalConvertUtil::decimal64FromDPD ( const unsigned char *  buffer)
inlinestatic

◆ decimal64FromDPD() [2/2]

void bdldfp::DecimalConvertUtil::decimal64FromDPD ( Decimal64 decimal,
const unsigned char *  buffer 
)
inlinestatic

◆ decimal64FromFloat()

static Decimal64 bdldfp::DecimalConvertUtil::decimal64FromFloat ( float  binary,
int  digits = 0 
)
static

◆ decimal64FromMultiWidthEncoding()

Decimal64 bdldfp::DecimalConvertUtil::decimal64FromMultiWidthEncoding ( const unsigned char *  buffer,
bsls::Types::size_type  size 
)
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.

◆ decimal64FromMultiWidthEncodingIfValid()

int bdldfp::DecimalConvertUtil::decimal64FromMultiWidthEncodingIfValid ( Decimal64 decimal,
const unsigned char *  buffer,
bsls::Types::size_type  size 
)
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.

◆ decimal64FromMultiWidthEncodingRaw()

Decimal64 bdldfp::DecimalConvertUtil::decimal64FromMultiWidthEncodingRaw ( const unsigned char *  buffer,
bsls::Types::size_type  size 
)
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.

◆ decimal64FromNetwork()

static const unsigned char * bdldfp::DecimalConvertUtil::decimal64FromNetwork ( Decimal64 decimal,
const unsigned char *  buffer 
)
static

◆ decimal64FromVariableWidthEncoding()

const unsigned char * bdldfp::DecimalConvertUtil::decimal64FromVariableWidthEncoding ( bdldfp::Decimal64 decimal,
const unsigned char *  buffer 
)
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.

◆ decimal64ToBID()

void bdldfp::DecimalConvertUtil::decimal64ToBID ( unsigned char *  buffer,
Decimal64  decimal 
)
inlinestatic

◆ decimal64ToDouble()

double bdldfp::DecimalConvertUtil::decimal64ToDouble ( Decimal64  decimal)
inlinestatic

◆ decimal64ToDPD()

void bdldfp::DecimalConvertUtil::decimal64ToDPD ( unsigned char *  buffer,
Decimal64  decimal 
)
inlinestatic

◆ decimal64ToFloat()

float bdldfp::DecimalConvertUtil::decimal64ToFloat ( Decimal64  decimal)
inlinestatic

◆ decimal64ToMultiWidthEncoding()

bsls::Types::size_type bdldfp::DecimalConvertUtil::decimal64ToMultiWidthEncoding ( unsigned char *  buffer,
bdldfp::Decimal64  decimal 
)
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).

◆ decimal64ToMultiWidthEncodingRaw()

bsls::Types::size_type bdldfp::DecimalConvertUtil::decimal64ToMultiWidthEncodingRaw ( unsigned char *  buffer,
bdldfp::Decimal64  decimal 
)
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.

◆ decimal64ToNetwork()

static unsigned char * bdldfp::DecimalConvertUtil::decimal64ToNetwork ( unsigned char *  buffer,
Decimal64  decimal 
)
static

◆ decimal64ToVariableWidthEncoding()

unsigned char * bdldfp::DecimalConvertUtil::decimal64ToVariableWidthEncoding ( unsigned char *  buffer,
bdldfp::Decimal64  decimal 
)
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).

◆ decimalFromBID() [1/3]

void bdldfp::DecimalConvertUtil::decimalFromBID ( Decimal128 decimal,
const unsigned char *  buffer 
)
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.

◆ decimalFromBID() [2/3]

void bdldfp::DecimalConvertUtil::decimalFromBID ( Decimal32 decimal,
const unsigned char *  buffer 
)
inlinestatic

◆ decimalFromBID() [3/3]

void bdldfp::DecimalConvertUtil::decimalFromBID ( Decimal64 decimal,
const unsigned char *  buffer 
)
inlinestatic

◆ decimalFromDPD() [1/3]

void bdldfp::DecimalConvertUtil::decimalFromDPD ( Decimal128 decimal,
const unsigned char *  buffer 
)
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.

◆ decimalFromDPD() [2/3]

void bdldfp::DecimalConvertUtil::decimalFromDPD ( Decimal32 decimal,
const unsigned char *  buffer 
)
inlinestatic

◆ decimalFromDPD() [3/3]

void bdldfp::DecimalConvertUtil::decimalFromDPD ( Decimal64 decimal,
const unsigned char *  buffer 
)
inlinestatic

◆ decimalFromNetwork() [1/3]

static const unsigned char * bdldfp::DecimalConvertUtil::decimalFromNetwork ( Decimal128 decimal,
const unsigned char *  buffer 
)
static

◆ decimalFromNetwork() [2/3]

static const unsigned char * bdldfp::DecimalConvertUtil::decimalFromNetwork ( Decimal32 decimal,
const unsigned char *  buffer 
)
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.

◆ decimalFromNetwork() [3/3]

static const unsigned char * bdldfp::DecimalConvertUtil::decimalFromNetwork ( Decimal64 decimal,
const unsigned char *  buffer 
)
static

◆ decimalToBID() [1/3]

void bdldfp::DecimalConvertUtil::decimalToBID ( unsigned char *  buffer,
Decimal128  decimal 
)
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.

◆ decimalToBID() [2/3]

void bdldfp::DecimalConvertUtil::decimalToBID ( unsigned char *  buffer,
Decimal32  decimal 
)
inlinestatic

◆ decimalToBID() [3/3]

void bdldfp::DecimalConvertUtil::decimalToBID ( unsigned char *  buffer,
Decimal64  decimal 
)
inlinestatic

◆ decimalToDouble() [1/3]

double bdldfp::DecimalConvertUtil::decimalToDouble ( Decimal128  decimal)
inlinestatic
  • If the decimal object is a NaN, return a NaN.
  • Otherwise if decimal is positive or negative infinity, return infinity of the same sign.
  • Otherwise if decimal is positive or negative zero, return zero of the same sign.
  • Otherwise if 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.
  • Otherwise if 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.
  • Otherwise if 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.
  • Otherwise if 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.
  • Otherwise use the exact value of the other object for the initialization if this object.

◆ decimalToDouble() [2/3]

double bdldfp::DecimalConvertUtil::decimalToDouble ( Decimal32  decimal)
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:

◆ decimalToDouble() [3/3]

double bdldfp::DecimalConvertUtil::decimalToDouble ( Decimal64  decimal)
inlinestatic

◆ decimalToDPD() [1/3]

void bdldfp::DecimalConvertUtil::decimalToDPD ( unsigned char *  buffer,
Decimal128  decimal 
)
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.

◆ decimalToDPD() [2/3]

void bdldfp::DecimalConvertUtil::decimalToDPD ( unsigned char *  buffer,
Decimal32  decimal 
)
inlinestatic

◆ decimalToDPD() [3/3]

void bdldfp::DecimalConvertUtil::decimalToDPD ( unsigned char *  buffer,
Decimal64  decimal 
)
inlinestatic

◆ decimalToFloat() [1/3]

float bdldfp::DecimalConvertUtil::decimalToFloat ( Decimal128  decimal)
inlinestatic
  • If the decimal object is a NaN, return a NaN.
  • Otherwise if decimal is positive or negative infinity, return infinity of the same sign.
  • Otherwise if decimal is positive or negative zero, return zero of the same sign.
  • Otherwise if 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.
  • Otherwise if 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.
  • Otherwise if 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.
  • Otherwise if 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.
  • Otherwise use the exact value of the other object for the initialization if this object.

◆ decimalToFloat() [2/3]

float bdldfp::DecimalConvertUtil::decimalToFloat ( Decimal32  decimal)
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:

◆ decimalToFloat() [3/3]

float bdldfp::DecimalConvertUtil::decimalToFloat ( Decimal64  decimal)
inlinestatic

◆ decimalToNetwork() [1/3]

static unsigned char * bdldfp::DecimalConvertUtil::decimalToNetwork ( unsigned char *  buffer,
Decimal128  decimal 
)
static

◆ decimalToNetwork() [2/3]

static unsigned char * bdldfp::DecimalConvertUtil::decimalToNetwork ( unsigned char *  buffer,
Decimal32  decimal 
)
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.

◆ decimalToNetwork() [3/3]

static unsigned char * bdldfp::DecimalConvertUtil::decimalToNetwork ( unsigned char *  buffer,
Decimal64  decimal 
)
static

◆ isValidMultiWidthSize()

bool bdldfp::DecimalConvertUtil::isValidMultiWidthSize ( bsls::Types::size_type  size)
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.


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