Next: , Previous: Soft float library routines, Up: Libgcc


4.3 Routines for decimal floating point emulation

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

4.3.1 Arithmetic functions

— Runtime Function: _Decimal32 __addsd3 (_Decimal32 a, _Decimal32 b)
— Runtime Function: _Decimal64 __adddd3 (_Decimal64 a, _Decimal64 b)
— Runtime Function: _Decimal128 __addtd3 (_Decimal128 a, _Decimal128 b)

These functions return the sum of a and b.

— Runtime Function: _Decimal32 __subsd3 (_Decimal32 a, _Decimal32 b)
— Runtime Function: _Decimal64 __subdd3 (_Decimal64 a, _Decimal64 b)
— Runtime Function: _Decimal128 __subtd3 (_Decimal128 a, _Decimal128 b)

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

— Runtime Function: _Decimal32 __mulsd3 (_Decimal32 a, _Decimal32 b)
— Runtime Function: _Decimal64 __muldd3 (_Decimal64 a, _Decimal64 b)
— Runtime Function: _Decimal128 __multd3 (_Decimal128 a, _Decimal128 b)

These functions return the product of a and b.

— Runtime Function: _Decimal32 __divsd3 (_Decimal32 a, _Decimal32 b)
— Runtime Function: _Decimal64 __divdd3 (_Decimal64 a, _Decimal64 b)
— Runtime Function: _Decimal128 __divtd3 (_Decimal128 a, _Decimal128 b)

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

— Runtime Function: _Decimal32 __negsd2 (_Decimal32 a)
— Runtime Function: _Decimal64 __negdd2 (_Decimal64 a)
— Runtime Function: _Decimal128 __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 __extendsddd2 (_Decimal32 a)
— Runtime Function: _Decimal128 __extendsdtd2 (_Decimal32 a)
— Runtime Function: _Decimal128 __extendddtd2 (_Decimal64 a)
— Runtime Function: _Decimal32 __extendsfsd (float a)
— Runtime Function: double __extendsddf (_Decimal32 a)
— Runtime Function: long double __extendsdxf (_Decimal32 a)
— Runtime Function: _Decimal64 __extendsfdd (float a)
— Runtime Function: _Decimal64 __extenddfdd (double a)
— Runtime Function: long double __extendddxf (_Decimal64 a)
— Runtime Function: _Decimal128 __extendsftd (float a)
— Runtime Function: _Decimal128 __extenddftd (double a)
— Runtime Function: _Decimal128 __extendxftd (long double a)

These functions extend a to the wider mode of their return type.

— Runtime Function: _Decimal32 __truncddsd2 (_Decimal64 a)
— Runtime Function: _Decimal32 __trunctdsd2 (_Decimal128 a)
— Runtime Function: _Decimal64 __trunctddd2 (_Decimal128 a)
— Runtime Function: float __truncsdsf (_Decimal32 a)
— Runtime Function: _Decimal32 __truncdfsd (double a)
— Runtime Function: _Decimal32 __truncxfsd (long double a)
— Runtime Function: float __truncddsf (_Decimal64 a)
— Runtime Function: double __truncdddf (_Decimal64 a)
— Runtime Function: _Decimal64 __truncxfdd (long double a)
— Runtime Function: float __trunctdsf (_Decimal128 a)
— Runtime Function: double __trunctddf (_Decimal128 a)
— Runtime Function: long double __trunctdxf (_Decimal128 a)

These functions truncate a to the narrower mode of their return type.

— Runtime Function: int __fixsdsi (_Decimal32 a)
— Runtime Function: int __fixddsi (_Decimal64 a)
— Runtime Function: int __fixtdsi (_Decimal128 a)

These functions convert a to a signed integer.

— Runtime Function: long __fixsddi (_Decimal32 a)
— Runtime Function: long __fixdddi (_Decimal64 a)
— Runtime Function: long __fixtddi (_Decimal128 a)

These functions convert a to a signed long.

— Runtime Function: unsigned int __fixunssdsi (_Decimal32 a)
— Runtime Function: unsigned int __fixunsddsi (_Decimal64 a)
— Runtime Function: unsigned int __fixunstdsi (_Decimal128 a)

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

— Runtime Function: unsigned long __fixunssddi (_Decimal32 a)
— Runtime Function: unsigned long __fixunsdddi (_Decimal64 a)
— Runtime Function: unsigned long __fixunstddi (_Decimal128 a)

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

— Runtime Function: _Decimal32 __floatsisd (int i)
— Runtime Function: _Decimal64 __floatsidd (int i)
— Runtime Function: _Decimal128 __floatsitd (int i)

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

— Runtime Function: _Decimal32 __floatdisd (long i)
— Runtime Function: _Decimal64 __floatdidd (long i)
— Runtime Function: _Decimal128 __floatditd (long i)

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

— Runtime Function: _Decimal32 __floatunssisd (unsigned int i)
— Runtime Function: _Decimal64 __floatunssidd (unsigned int i)
— Runtime Function: _Decimal128 __floatunssitd (unsigned int i)

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

— Runtime Function: _Decimal32 __floatunsdisd (unsigned long i)
— Runtime Function: _Decimal64 __floatunsdidd (unsigned long i)
— Runtime Function: _Decimal128 __floatunsditd (unsigned long i)

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

4.3.3 Comparison functions

— Runtime Function: int __unordsd2 (_Decimal32 a, _Decimal32 b)
— Runtime Function: int __unorddd2 (_Decimal64 a, _Decimal64 b)
— Runtime Function: int __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 (__unordXd2 (a, b))
         return E;
       return __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 __eqsd2 (_Decimal32 a, _Decimal32 b)
— Runtime Function: int __eqdd2 (_Decimal64 a, _Decimal64 b)
— Runtime Function: int __eqtd2 (_Decimal128 a, _Decimal128 b)

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

— Runtime Function: int __nesd2 (_Decimal32 a, _Decimal32 b)
— Runtime Function: int __nedd2 (_Decimal64 a, _Decimal64 b)
— Runtime Function: int __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 __gesd2 (_Decimal32 a, _Decimal32 b)
— Runtime Function: int __gedd2 (_Decimal64 a, _Decimal64 b)
— Runtime Function: int __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 __ltsd2 (_Decimal32 a, _Decimal32 b)
— Runtime Function: int __ltdd2 (_Decimal64 a, _Decimal64 b)
— Runtime Function: int __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 __lesd2 (_Decimal32 a, _Decimal32 b)
— Runtime Function: int __ledd2 (_Decimal64 a, _Decimal64 b)
— Runtime Function: int __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 __gtsd2 (_Decimal32 a, _Decimal32 b)
— Runtime Function: int __gtdd2 (_Decimal64 a, _Decimal64 b)
— Runtime Function: int __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.