Movatterモバイル変換


[0]ホーム

URL:


Next:, Previous:, Up:The GCC low-level runtime library   [Contents][Index]


3.3 Routines for decimal floating point emulation

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

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

3.3.1 Arithmetic functions

Runtime Function:_Decimal32__dpd_addsd3(_Decimal32a, _Decimal32b)
Runtime Function:_Decimal32__bid_addsd3(_Decimal32a, _Decimal32b)
Runtime Function:_Decimal64__dpd_adddd3(_Decimal64a, _Decimal64b)
Runtime Function:_Decimal64__bid_adddd3(_Decimal64a, _Decimal64b)
Runtime Function:_Decimal128__dpd_addtd3(_Decimal128a, _Decimal128b)
Runtime Function:_Decimal128__bid_addtd3(_Decimal128a, _Decimal128b)

These functions return the sum ofa andb.

Runtime Function:_Decimal32__dpd_subsd3(_Decimal32a, _Decimal32b)
Runtime Function:_Decimal32__bid_subsd3(_Decimal32a, _Decimal32b)
Runtime Function:_Decimal64__dpd_subdd3(_Decimal64a, _Decimal64b)
Runtime Function:_Decimal64__bid_subdd3(_Decimal64a, _Decimal64b)
Runtime Function:_Decimal128__dpd_subtd3(_Decimal128a, _Decimal128b)
Runtime Function:_Decimal128__bid_subtd3(_Decimal128a, _Decimal128b)

These functions return the difference betweenb anda;that is,a -b.

Runtime Function:_Decimal32__dpd_mulsd3(_Decimal32a, _Decimal32b)
Runtime Function:_Decimal32__bid_mulsd3(_Decimal32a, _Decimal32b)
Runtime Function:_Decimal64__dpd_muldd3(_Decimal64a, _Decimal64b)
Runtime Function:_Decimal64__bid_muldd3(_Decimal64a, _Decimal64b)
Runtime Function:_Decimal128__dpd_multd3(_Decimal128a, _Decimal128b)
Runtime Function:_Decimal128__bid_multd3(_Decimal128a, _Decimal128b)

These functions return the product ofa andb.

Runtime Function:_Decimal32__dpd_divsd3(_Decimal32a, _Decimal32b)
Runtime Function:_Decimal32__bid_divsd3(_Decimal32a, _Decimal32b)
Runtime Function:_Decimal64__dpd_divdd3(_Decimal64a, _Decimal64b)
Runtime Function:_Decimal64__bid_divdd3(_Decimal64a, _Decimal64b)
Runtime Function:_Decimal128__dpd_divtd3(_Decimal128a, _Decimal128b)
Runtime Function:_Decimal128__bid_divtd3(_Decimal128a, _Decimal128b)

These functions return the quotient ofa andb; that is,a /b.

Runtime Function:_Decimal32__dpd_negsd2(_Decimal32a)
Runtime Function:_Decimal32__bid_negsd2(_Decimal32a)
Runtime Function:_Decimal64__dpd_negdd2(_Decimal64a)
Runtime Function:_Decimal64__bid_negdd2(_Decimal64a)
Runtime Function:_Decimal128__dpd_negtd2(_Decimal128a)
Runtime Function:_Decimal128__bid_negtd2(_Decimal128a)

These functions return the negation ofa. They simply flip thesign bit, so they can produce negative zero and negative NaN.

3.3.2 Conversion functions

Runtime Function:_Decimal64__dpd_extendsddd2(_Decimal32a)
Runtime Function:_Decimal64__bid_extendsddd2(_Decimal32a)
Runtime Function:_Decimal128__dpd_extendsdtd2(_Decimal32a)
Runtime Function:_Decimal128__bid_extendsdtd2(_Decimal32a)
Runtime Function:_Decimal128__dpd_extendddtd2(_Decimal64a)
Runtime Function:_Decimal128__bid_extendddtd2(_Decimal64a)
Runtime Function:_Decimal32__dpd_truncddsd2(_Decimal64a)
Runtime Function:_Decimal32__bid_truncddsd2(_Decimal64a)
Runtime Function:_Decimal32__dpd_trunctdsd2(_Decimal128a)
Runtime Function:_Decimal32__bid_trunctdsd2(_Decimal128a)
Runtime Function:_Decimal64__dpd_trunctddd2(_Decimal128a)
Runtime Function:_Decimal64__bid_trunctddd2(_Decimal128a)

These functions convert the valuea from one decimal floating typeto another.

Runtime Function:_Decimal64__dpd_extendsfdd(floata)
Runtime Function:_Decimal64__bid_extendsfdd(floata)
Runtime Function:_Decimal128__dpd_extendsftd(floata)
Runtime Function:_Decimal128__bid_extendsftd(floata)
Runtime Function:_Decimal128__dpd_extenddftd(doublea)
Runtime Function:_Decimal128__bid_extenddftd(doublea)
Runtime Function:_Decimal128__dpd_extendxftd(long doublea)
Runtime Function:_Decimal128__bid_extendxftd(long doublea)
Runtime Function:_Decimal32__dpd_truncdfsd(doublea)
Runtime Function:_Decimal32__bid_truncdfsd(doublea)
Runtime Function:_Decimal32__dpd_truncxfsd(long doublea)
Runtime Function:_Decimal32__bid_truncxfsd(long doublea)
Runtime Function:_Decimal32__dpd_trunctfsd(long doublea)
Runtime Function:_Decimal32__bid_trunctfsd(long doublea)
Runtime Function:_Decimal64__dpd_truncxfdd(long doublea)
Runtime Function:_Decimal64__bid_truncxfdd(long doublea)
Runtime Function:_Decimal64__dpd_trunctfdd(long doublea)
Runtime Function:_Decimal64__bid_trunctfdd(long doublea)

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

Runtime Function:float__dpd_truncddsf(_Decimal64a)
Runtime Function:float__bid_truncddsf(_Decimal64a)
Runtime Function:float__dpd_trunctdsf(_Decimal128a)
Runtime Function:float__bid_trunctdsf(_Decimal128a)
Runtime Function:double__dpd_extendsddf(_Decimal32a)
Runtime Function:double__bid_extendsddf(_Decimal32a)
Runtime Function:double__dpd_trunctddf(_Decimal128a)
Runtime Function:double__bid_trunctddf(_Decimal128a)
Runtime Function:long double__dpd_extendsdxf(_Decimal32a)
Runtime Function:long double__bid_extendsdxf(_Decimal32a)
Runtime Function:long double__dpd_extendddxf(_Decimal64a)
Runtime Function:long double__bid_extendddxf(_Decimal64a)
Runtime Function:long double__dpd_trunctdxf(_Decimal128a)
Runtime Function:long double__bid_trunctdxf(_Decimal128a)
Runtime Function:long double__dpd_extendsdtf(_Decimal32a)
Runtime Function:long double__bid_extendsdtf(_Decimal32a)
Runtime Function:long double__dpd_extendddtf(_Decimal64a)
Runtime Function:long double__bid_extendddtf(_Decimal64a)

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

Runtime Function:_Decimal32__dpd_extendsfsd(floata)
Runtime Function:_Decimal32__bid_extendsfsd(floata)
Runtime Function:_Decimal64__dpd_extenddfdd(doublea)
Runtime Function:_Decimal64__bid_extenddfdd(doublea)
Runtime Function:_Decimal128__dpd_extendtftd(long doublea)
Runtime Function:_Decimal128__bid_extendtftd(long doublea)
Runtime Function:float__dpd_truncsdsf(_Decimal32a)
Runtime Function:float__bid_truncsdsf(_Decimal32a)
Runtime Function:double__dpd_truncdddf(_Decimal64a)
Runtime Function:double__bid_truncdddf(_Decimal64a)
Runtime Function:long double__dpd_trunctdtf(_Decimal128a)
Runtime Function:long double__bid_trunctdtf(_Decimal128a)

These functions convert the value ofa between decimal andbinary floating types of the same size.

Runtime Function:int__dpd_fixsdsi(_Decimal32a)
Runtime Function:int__bid_fixsdsi(_Decimal32a)
Runtime Function:int__dpd_fixddsi(_Decimal64a)
Runtime Function:int__bid_fixddsi(_Decimal64a)
Runtime Function:int__dpd_fixtdsi(_Decimal128a)
Runtime Function:int__bid_fixtdsi(_Decimal128a)

These functions converta to a signed integer.

Runtime Function:long__dpd_fixsddi(_Decimal32a)
Runtime Function:long__bid_fixsddi(_Decimal32a)
Runtime Function:long__dpd_fixdddi(_Decimal64a)
Runtime Function:long__bid_fixdddi(_Decimal64a)
Runtime Function:long__dpd_fixtddi(_Decimal128a)
Runtime Function:long__bid_fixtddi(_Decimal128a)

These functions converta to a signed long.

Runtime Function:unsigned int__dpd_fixunssdsi(_Decimal32a)
Runtime Function:unsigned int__bid_fixunssdsi(_Decimal32a)
Runtime Function:unsigned int__dpd_fixunsddsi(_Decimal64a)
Runtime Function:unsigned int__bid_fixunsddsi(_Decimal64a)
Runtime Function:unsigned int__dpd_fixunstdsi(_Decimal128a)
Runtime Function:unsigned int__bid_fixunstdsi(_Decimal128a)

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

Runtime Function:unsigned long__dpd_fixunssddi(_Decimal32a)
Runtime Function:unsigned long__bid_fixunssddi(_Decimal32a)
Runtime Function:unsigned long__dpd_fixunsdddi(_Decimal64a)
Runtime Function:unsigned long__bid_fixunsdddi(_Decimal64a)
Runtime Function:unsigned long__dpd_fixunstddi(_Decimal128a)
Runtime Function:unsigned long__bid_fixunstddi(_Decimal128a)

These functions converta to an unsigned long. Negative valuesall become zero.

Runtime Function:_Decimal32__dpd_floatsisd(inti)
Runtime Function:_Decimal32__bid_floatsisd(inti)
Runtime Function:_Decimal64__dpd_floatsidd(inti)
Runtime Function:_Decimal64__bid_floatsidd(inti)
Runtime Function:_Decimal128__dpd_floatsitd(inti)
Runtime Function:_Decimal128__bid_floatsitd(inti)

These functions converti, a signed integer, to decimal floating point.

Runtime Function:_Decimal32__dpd_floatdisd(longi)
Runtime Function:_Decimal32__bid_floatdisd(longi)
Runtime Function:_Decimal64__dpd_floatdidd(longi)
Runtime Function:_Decimal64__bid_floatdidd(longi)
Runtime Function:_Decimal128__dpd_floatditd(longi)
Runtime Function:_Decimal128__bid_floatditd(longi)

These functions converti, a signed long, to decimal floating point.

Runtime Function:_Decimal32__dpd_floatunssisd(unsigned inti)
Runtime Function:_Decimal32__bid_floatunssisd(unsigned inti)
Runtime Function:_Decimal64__dpd_floatunssidd(unsigned inti)
Runtime Function:_Decimal64__bid_floatunssidd(unsigned inti)
Runtime Function:_Decimal128__dpd_floatunssitd(unsigned inti)
Runtime Function:_Decimal128__bid_floatunssitd(unsigned inti)

These functions converti, an unsigned integer, to decimal floating point.

Runtime Function:_Decimal32__dpd_floatunsdisd(unsigned longi)
Runtime Function:_Decimal32__bid_floatunsdisd(unsigned longi)
Runtime Function:_Decimal64__dpd_floatunsdidd(unsigned longi)
Runtime Function:_Decimal64__bid_floatunsdidd(unsigned longi)
Runtime Function:_Decimal128__dpd_floatunsditd(unsigned longi)
Runtime Function:_Decimal128__bid_floatunsditd(unsigned longi)

These functions converti, an unsigned long, to decimal floating point.

Runtime Function:void__bid_fixsdbitint(UBILtype *r, int32_trprec, _Decimal32a)
Runtime Function:void__bid_fixddbitint(UBILtype *r, int32_trprec, _Decimal64a)
Runtime Function:void__bid_fixtdbitint(UBILtype *r, int32_trprec, _Decimal128a)

These functions converta to bit-precise integerr, rounding toward zero.Ifrprec is positive, it converts to unsigned bit-precise integer andnegative values all become zero, ifrprec is negative, it convertsto signed bit-precise integer. So far implemented for BID format only.

Runtime Function:_Decimal32__bid_floatbitintsd(UBILtype *i, int32_tiprec)
Runtime Function:_Decimal64__bid_floatbitintdd(UBILtype *i, int32_tiprec)
Runtime Function:_Decimal128__bid_floatbitinttd(UBILtype *i, int32_tiprec)

These functions convert bit-precise integeri to decimal floating point. Ifiprec is positive, it is conversion from unsigned bit-precise integer,otherwise from signed bit-precise integer. So far implemented for BID format only.

3.3.3 Comparison functions

Runtime Function:int__dpd_unordsd2(_Decimal32a, _Decimal32b)
Runtime Function:int__bid_unordsd2(_Decimal32a, _Decimal32b)
Runtime Function:int__dpd_unorddd2(_Decimal64a, _Decimal64b)
Runtime Function:int__bid_unorddd2(_Decimal64a, _Decimal64b)
Runtime Function:int__dpd_unordtd2(_Decimal128a, _Decimal128b)
Runtime Function:int__bid_unordtd2(_Decimal128a, _Decimal128b)

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

There is also a complete group of higher level functions whichcorrespond directly to comparison operators. They implement the ISO Csemantics 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))    returnE;  return __bid_cmpXd2 (a, b);

whereE is a constant chosen to give the proper behavior forNaN. Thus, the meaning of the return value is different for each set.Do not rely on this implementation; only the semantics documentedbelow are guaranteed.

Runtime Function:int__dpd_eqsd2(_Decimal32a, _Decimal32b)
Runtime Function:int__bid_eqsd2(_Decimal32a, _Decimal32b)
Runtime Function:int__dpd_eqdd2(_Decimal64a, _Decimal64b)
Runtime Function:int__bid_eqdd2(_Decimal64a, _Decimal64b)
Runtime Function:int__dpd_eqtd2(_Decimal128a, _Decimal128b)
Runtime Function:int__bid_eqtd2(_Decimal128a, _Decimal128b)

These functions return zero if neither argument is NaN, anda andb are equal.

Runtime Function:int__dpd_nesd2(_Decimal32a, _Decimal32b)
Runtime Function:int__bid_nesd2(_Decimal32a, _Decimal32b)
Runtime Function:int__dpd_nedd2(_Decimal64a, _Decimal64b)
Runtime Function:int__bid_nedd2(_Decimal64a, _Decimal64b)
Runtime Function:int__dpd_netd2(_Decimal128a, _Decimal128b)
Runtime Function:int__bid_netd2(_Decimal128a, _Decimal128b)

These functions return a nonzero value if either argument is NaN, orifa andb are unequal.

Runtime Function:int__dpd_gesd2(_Decimal32a, _Decimal32b)
Runtime Function:int__bid_gesd2(_Decimal32a, _Decimal32b)
Runtime Function:int__dpd_gedd2(_Decimal64a, _Decimal64b)
Runtime Function:int__bid_gedd2(_Decimal64a, _Decimal64b)
Runtime Function:int__dpd_getd2(_Decimal128a, _Decimal128b)
Runtime Function:int__bid_getd2(_Decimal128a, _Decimal128b)

These functions return a value greater than or equal to zero ifneither argument is NaN, anda is greater than or equal tob.

Runtime Function:int__dpd_ltsd2(_Decimal32a, _Decimal32b)
Runtime Function:int__bid_ltsd2(_Decimal32a, _Decimal32b)
Runtime Function:int__dpd_ltdd2(_Decimal64a, _Decimal64b)
Runtime Function:int__bid_ltdd2(_Decimal64a, _Decimal64b)
Runtime Function:int__dpd_lttd2(_Decimal128a, _Decimal128b)
Runtime Function:int__bid_lttd2(_Decimal128a, _Decimal128b)

These functions return a value less than zero if neither argument isNaN, anda is strictly less thanb.

Runtime Function:int__dpd_lesd2(_Decimal32a, _Decimal32b)
Runtime Function:int__bid_lesd2(_Decimal32a, _Decimal32b)
Runtime Function:int__dpd_ledd2(_Decimal64a, _Decimal64b)
Runtime Function:int__bid_ledd2(_Decimal64a, _Decimal64b)
Runtime Function:int__dpd_letd2(_Decimal128a, _Decimal128b)
Runtime Function:int__bid_letd2(_Decimal128a, _Decimal128b)

These functions return a value less than or equal to zero if neitherargument is NaN, anda is less than or equal tob.

Runtime Function:int__dpd_gtsd2(_Decimal32a, _Decimal32b)
Runtime Function:int__bid_gtsd2(_Decimal32a, _Decimal32b)
Runtime Function:int__dpd_gtdd2(_Decimal64a, _Decimal64b)
Runtime Function:int__bid_gtdd2(_Decimal64a, _Decimal64b)
Runtime Function:int__dpd_gttd2(_Decimal128a, _Decimal128b)
Runtime Function:int__bid_gttd2(_Decimal128a, _Decimal128b)

These functions return a value greater than zero if neither argumentis NaN, anda is strictly greater thanb.


Next:Routines for fixed-point fractional emulation, Previous:Routines for floating point emulation, Up:The GCC low-level runtime library   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp