GNU Compiler Collection (GCC) Internals: Decimal float library routines

Next: Fixed-point fractional library routines, Previous: Soft float library routines, Up: Libgcc [Contents][Index]

### 4.3 Routines for decimal floating point emulation

The software decimal floating point library implements IEEE 754-2008 decimal floating point arithmetic and is only activated on selected targets.

The software decimal floating point library supports either DPD (Densely Packed Decimal) or BID (Binary Integer Decimal) encoding as selected at configure time.

#### 4.3.1 Arithmetic functions

Runtime Function: _Decimal32 __dpd_addsd3 (_Decimal32 a, _Decimal32 b)
Runtime Function: _Decimal32 __bid_addsd3 (_Decimal32 a, _Decimal32 b)
Runtime Function: _Decimal64 __dpd_adddd3 (_Decimal64 a, _Decimal64 b)
Runtime Function: _Decimal64 __bid_adddd3 (_Decimal64 a, _Decimal64 b)
Runtime Function: _Decimal128 __dpd_addtd3 (_Decimal128 a, _Decimal128 b)
Runtime Function: _Decimal128 __bid_addtd3 (_Decimal128 a, _Decimal128 b)

  These functions return the sum of a and b.

Runtime Function: _Decimal32 __dpd_subsd3 (_Decimal32 a, _Decimal32 b)
Runtime Function: _Decimal32 __bid_subsd3 (_Decimal32 a, _Decimal32 b)
Runtime Function: _Decimal64 __dpd_subdd3 (_Decimal64 a, _Decimal64 b)
Runtime Function: _Decimal64 __bid_subdd3 (_Decimal64 a, _Decimal64 b)
Runtime Function: _Decimal128 __dpd_subtd3 (_Decimal128 a, _Decimal128 b)
Runtime Function: _Decimal128 __bid_subtd3 (_Decimal128 a, _Decimal128 b)

  These functions return the difference between b and a; that is, a - b.

Runtime Function: _Decimal32 __dpd_mulsd3 (_Decimal32 a, _Decimal32 b)
Runtime Function: _Decimal32 __bid_mulsd3 (_Decimal32 a, _Decimal32 b)
Runtime Function: _Decimal64 __dpd_muldd3 (_Decimal64 a, _Decimal64 b)
Runtime Function: _Decimal64 __bid_muldd3 (_Decimal64 a, _Decimal64 b)
Runtime Function: _Decimal128 __dpd_multd3 (_Decimal128 a, _Decimal128 b)
Runtime Function: _Decimal128 __bid_multd3 (_Decimal128 a, _Decimal128 b)

  These functions return the product of a and b.

Runtime Function: _Decimal32 __dpd_divsd3 (_Decimal32 a, _Decimal32 b)
Runtime Function: _Decimal32 __bid_divsd3 (_Decimal32 a, _Decimal32 b)
Runtime Function: _Decimal64 __dpd_divdd3 (_Decimal64 a, _Decimal64 b)
Runtime Function: _Decimal64 __bid_divdd3 (_Decimal64 a, _Decimal64 b)
Runtime Function: _Decimal128 __dpd_divtd3 (_Decimal128 a, _Decimal128 b)
Runtime Function: _Decimal128 __bid_divtd3 (_Decimal128 a, _Decimal128 b)

  These functions return the quotient of a and b; that is, a / b.

Runtime Function: _Decimal32 __dpd_negsd2 (_Decimal32 a)
Runtime Function: _Decimal32 __bid_negsd2 (_Decimal32 a)
Runtime Function: _Decimal64 __dpd_negdd2 (_Decimal64 a)
Runtime Function: _Decimal64 __bid_negdd2 (_Decimal64 a)
Runtime Function: _Decimal128 __dpd_negtd2 (_Decimal128 a)
Runtime Function: _Decimal128 __bid_negtd2 (_Decimal128 a)

  These functions return the negation of a. They simply flip the sign bit, so they can produce negative zero and negative NaN.

#### 4.3.2 Conversion functions

Runtime Function: _Decimal64 __dpd_extendsddd2 (_Decimal32 a)
Runtime Function: _Decimal64 __bid_extendsddd2 (_Decimal32 a)
Runtime Function: _Decimal128 __dpd_extendsdtd2 (_Decimal32 a)
Runtime Function: _Decimal128 __bid_extendsdtd2 (_Decimal32 a)
Runtime Function: _Decimal128 __dpd_extendddtd2 (_Decimal64 a)
Runtime Function: _Decimal128 __bid_extendddtd2 (_Decimal64 a)
Runtime Function: _Decimal32 __dpd_truncddsd2 (_Decimal64 a)
Runtime Function: _Decimal32 __bid_truncddsd2 (_Decimal64 a)
Runtime Function: _Decimal32 __dpd_trunctdsd2 (_Decimal128 a)
Runtime Function: _Decimal32 __bid_trunctdsd2 (_Decimal128 a)
Runtime Function: _Decimal64 __dpd_trunctddd2 (_Decimal128 a)
Runtime Function: _Decimal64 __bid_trunctddd2 (_Decimal128 a)

  These functions convert the value a from one decimal floating type to another.

Runtime Function: _Decimal64 __dpd_extendsfdd (float a)
Runtime Function: _Decimal64 __bid_extendsfdd (float a)
Runtime Function: _Decimal128 __dpd_extendsftd (float a)
Runtime Function: _Decimal128 __bid_extendsftd (float a)
Runtime Function: _Decimal128 __dpd_extenddftd (double a)
Runtime Function: _Decimal128 __bid_extenddftd (double a)
Runtime Function: _Decimal128 __dpd_extendxftd (long double a)
Runtime Function: _Decimal128 __bid_extendxftd (long double a)
Runtime Function: _Decimal32 __dpd_truncdfsd (double a)
Runtime Function: _Decimal32 __bid_truncdfsd (double a)
Runtime Function: _Decimal32 __dpd_truncxfsd (long double a)
Runtime Function: _Decimal32 __bid_truncxfsd (long double a)
Runtime Function: _Decimal32 __dpd_trunctfsd (long double a)
Runtime Function: _Decimal32 __bid_trunctfsd (long double a)
Runtime Function: _Decimal64 __dpd_truncxfdd (long double a)
Runtime Function: _Decimal64 __bid_truncxfdd (long double a)
Runtime Function: _Decimal64 __dpd_trunctfdd (long double a)
Runtime Function: _Decimal64 __bid_trunctfdd (long double a)

  These functions convert the value of a from a binary floating type to a decimal floating type of a different size.

Runtime Function: float __dpd_truncddsf (_Decimal64 a)
Runtime Function: float __bid_truncddsf (_Decimal64 a)
Runtime Function: float __dpd_trunctdsf (_Decimal128 a)
Runtime Function: float __bid_trunctdsf (_Decimal128 a)
Runtime Function: double __dpd_extendsddf (_Decimal32 a)
Runtime Function: double __bid_extendsddf (_Decimal32 a)
Runtime Function: double __dpd_trunctddf (_Decimal128 a)
Runtime Function: double __bid_trunctddf (_Decimal128 a)
Runtime Function: long double __dpd_extendsdxf (_Decimal32 a)
Runtime Function: long double __bid_extendsdxf (_Decimal32 a)
Runtime Function: long double __dpd_extendddxf (_Decimal64 a)
Runtime Function: long double __bid_extendddxf (_Decimal64 a)
Runtime Function: long double __dpd_trunctdxf (_Decimal128 a)
Runtime Function: long double __bid_trunctdxf (_Decimal128 a)
Runtime Function: long double __dpd_extendsdtf (_Decimal32 a)
Runtime Function: long double __bid_extendsdtf (_Decimal32 a)
Runtime Function: long double __dpd_extendddtf (_Decimal64 a)
Runtime Function: long double __bid_extendddtf (_Decimal64 a)

  These functions convert the value of a from a decimal floating type to a binary floating type of a different size.

Runtime Function: _Decimal32 __dpd_extendsfsd (float a)
Runtime Function: _Decimal32 __bid_extendsfsd (float a)
Runtime Function: _Decimal64 __dpd_extenddfdd (double a)
Runtime Function: _Decimal64 __bid_extenddfdd (double a)
Runtime Function: _Decimal128 __dpd_extendtftd (long double a)
Runtime Function: _Decimal128 __bid_extendtftd (long double a)
Runtime Function: float __dpd_truncsdsf (_Decimal32 a)
Runtime Function: float __bid_truncsdsf (_Decimal32 a)
Runtime Function: double __dpd_truncdddf (_Decimal64 a)
Runtime Function: double __bid_truncdddf (_Decimal64 a)
Runtime Function: long double __dpd_trunctdtf (_Decimal128 a)
Runtime Function: long double __bid_trunctdtf (_Decimal128 a)

  These functions convert the value of a between decimal and binary floating types of the same size.

Runtime Function: int __dpd_fixsdsi (_Decimal32 a)
Runtime Function: int __bid_fixsdsi (_Decimal32 a)
Runtime Function: int __dpd_fixddsi (_Decimal64 a)
Runtime Function: int __bid_fixddsi (_Decimal64 a)
Runtime Function: int __dpd_fixtdsi (_Decimal128 a)
Runtime Function: int __bid_fixtdsi (_Decimal128 a)

  These functions convert a to a signed integer.

Runtime Function: long __dpd_fixsddi (_Decimal32 a)
Runtime Function: long __bid_fixsddi (_Decimal32 a)
Runtime Function: long __dpd_fixdddi (_Decimal64 a)
Runtime Function: long __bid_fixdddi (_Decimal64 a)
Runtime Function: long __dpd_fixtddi (_Decimal128 a)
Runtime Function: long __bid_fixtddi (_Decimal128 a)

  These functions convert a to a signed long.

Runtime Function: unsigned int __dpd_fixunssdsi (_Decimal32 a)
Runtime Function: unsigned int __bid_fixunssdsi (_Decimal32 a)
Runtime Function: unsigned int __dpd_fixunsddsi (_Decimal64 a)
Runtime Function: unsigned int __bid_fixunsddsi (_Decimal64 a)
Runtime Function: unsigned int __dpd_fixunstdsi (_Decimal128 a)
Runtime Function: unsigned int __bid_fixunstdsi (_Decimal128 a)

  These functions convert a to an unsigned integer. Negative values all become zero.

Runtime Function: unsigned long __dpd_fixunssddi (_Decimal32 a)
Runtime Function: unsigned long __bid_fixunssddi (_Decimal32 a)
Runtime Function: unsigned long __dpd_fixunsdddi (_Decimal64 a)
Runtime Function: unsigned long __bid_fixunsdddi (_Decimal64 a)
Runtime Function: unsigned long __dpd_fixunstddi (_Decimal128 a)
Runtime Function: unsigned long __bid_fixunstddi (_Decimal128 a)

  These functions convert a to an unsigned long. Negative values all become zero.

Runtime Function: _Decimal32 __dpd_floatsisd (int i)
Runtime Function: _Decimal32 __bid_floatsisd (int i)
Runtime Function: _Decimal64 __dpd_floatsidd (int i)
Runtime Function: _Decimal64 __bid_floatsidd (int i)
Runtime Function: _Decimal128 __dpd_floatsitd (int i)
Runtime Function: _Decimal128 __bid_floatsitd (int i)

  These functions convert i, a signed integer, to decimal floating point.

Runtime Function: _Decimal32 __dpd_floatdisd (long i)
Runtime Function: _Decimal32 __bid_floatdisd (long i)
Runtime Function: _Decimal64 __dpd_floatdidd (long i)
Runtime Function: _Decimal64 __bid_floatdidd (long i)
Runtime Function: _Decimal128 __dpd_floatditd (long i)
Runtime Function: _Decimal128 __bid_floatditd (long i)

  These functions convert i, a signed long, to decimal floating point.

Runtime Function: _Decimal32 __dpd_floatunssisd (unsigned int i)
Runtime Function: _Decimal32 __bid_floatunssisd (unsigned int i)
Runtime Function: _Decimal64 __dpd_floatunssidd (unsigned int i)
Runtime Function: _Decimal64 __bid_floatunssidd (unsigned int i)
Runtime Function: _Decimal128 __dpd_floatunssitd (unsigned int i)
Runtime Function: _Decimal128 __bid_floatunssitd (unsigned int i)

  These functions convert i, an unsigned integer, to decimal floating point.

Runtime Function: _Decimal32 __dpd_floatunsdisd (unsigned long i)
Runtime Function: _Decimal32 __bid_floatunsdisd (unsigned long i)
Runtime Function: _Decimal64 __dpd_floatunsdidd (unsigned long i)
Runtime Function: _Decimal64 __bid_floatunsdidd (unsigned long i)
Runtime Function: _Decimal128 __dpd_floatunsditd (unsigned long i)
Runtime Function: _Decimal128 __bid_floatunsditd (unsigned long i)

  These functions convert i, an unsigned long, to decimal floating point.

#### 4.3.3 Comparison functions

Runtime Function: int __dpd_unordsd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __bid_unordsd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __dpd_unorddd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __bid_unorddd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __dpd_unordtd2 (_Decimal128 a, _Decimal128 b)
Runtime Function: int __bid_unordtd2 (_Decimal128 a, _Decimal128 b)

  These functions return a nonzero value if either argument is NaN, otherwise 0.

There is also a complete group of higher level functions which correspond directly to comparison operators. They implement the ISO C semantics for floating-point comparisons, taking NaN into account. Pay careful attention to the return values defined for each set. Under the hood, all of these routines are implemented as

      if (__bid_unordXd2 (a, b))
        return E;
      return __bid_cmpXd2 (a, b);

where E is a constant chosen to give the proper behavior for NaN. Thus, the meaning of the return value is different for each set. Do not rely on this implementation; only the semantics documented below are guaranteed.

Runtime Function: int __dpd_eqsd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __bid_eqsd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __dpd_eqdd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __bid_eqdd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __dpd_eqtd2 (_Decimal128 a, _Decimal128 b)
Runtime Function: int __bid_eqtd2 (_Decimal128 a, _Decimal128 b)

  These functions return zero if neither argument is NaN, and a and b are equal.

Runtime Function: int __dpd_nesd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __bid_nesd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __dpd_nedd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __bid_nedd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __dpd_netd2 (_Decimal128 a, _Decimal128 b)
Runtime Function: int __bid_netd2 (_Decimal128 a, _Decimal128 b)

  These functions return a nonzero value if either argument is NaN, or if a and b are unequal.

Runtime Function: int __dpd_gesd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __bid_gesd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __dpd_gedd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __bid_gedd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __dpd_getd2 (_Decimal128 a, _Decimal128 b)
Runtime Function: int __bid_getd2 (_Decimal128 a, _Decimal128 b)

  These functions return a value greater than or equal to zero if neither argument is NaN, and a is greater than or equal to b.

Runtime Function: int __dpd_ltsd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __bid_ltsd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __dpd_ltdd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __bid_ltdd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __dpd_lttd2 (_Decimal128 a, _Decimal128 b)
Runtime Function: int __bid_lttd2 (_Decimal128 a, _Decimal128 b)

  These functions return a value less than zero if neither argument is NaN, and a is strictly less than b.

Runtime Function: int __dpd_lesd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __bid_lesd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __dpd_ledd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __bid_ledd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __dpd_letd2 (_Decimal128 a, _Decimal128 b)
Runtime Function: int __bid_letd2 (_Decimal128 a, _Decimal128 b)

  These functions return a value less than or equal to zero if neither argument is NaN, and a is less than or equal to b.

Runtime Function: int __dpd_gtsd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __bid_gtsd2 (_Decimal32 a, _Decimal32 b)
Runtime Function: int __dpd_gtdd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __bid_gtdd2 (_Decimal64 a, _Decimal64 b)
Runtime Function: int __dpd_gttd2 (_Decimal128 a, _Decimal128 b)
Runtime Function: int __bid_gttd2 (_Decimal128 a, _Decimal128 b)

  These functions return a value greater than zero if neither argument is NaN, and a is strictly greater than b.

Next: Fixed-point fractional library routines, Previous: Soft float library routines, Up: Libgcc [Contents][Index]