BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdldfp_decimalutil

Detailed Description

Outline

Purpose

Provide utilities dealing with floating point decimal objects.

Classes

Macros

Note that these macros may not be defined in this header. They are C99 standard macros and this component defines them only for those platforms that have failed to implement C99 (such as Microsoft).

See also
bdldfp_decimal, bdldfp_decimalplatform

Description

The bdldfp::DecimalUtil component provides utility functions for the decimal floating-point types defined in bdldfp_decimal :

The FP_XXX C99 floating-point classification macros may also be provided by this header for platforms where C99 support is still not provided.

Usage

This section shows the intended use of this component.

Example 1: Building Decimals From Integer Parts

Floating-point numbers are built from a sign, a significand and an exponent. All those 3 are integers (of various sizes), therefore it is possible to build decimals from integers:

long long coefficient = 42; // Yet another name for significand
int exponent = -1;
Decimal32 d32 = makeDecimal32( coefficient, exponent);
Decimal64 d64 = makeDecimal64( coefficient, exponent);
Decimal128 d128 = makeDecimal128(coefficient, exponent);
assert(BDLDFP_DECIMAL_DF(4.2) == d32);
assert(BDLDFP_DECIMAL_DD(4.2) == d64);
assert(BDLDFP_DECIMAL_DL(4.2) == d128);
#define BDLDFP_DECIMAL_DF(lit)
Definition bdldfp_decimal.h:702
#define BDLDFP_DECIMAL_DD(lit)
Definition bdldfp_decimal.h:705
#define BDLDFP_DECIMAL_DL(lit)
Definition bdldfp_decimal.h:708