#ifndef FINE_GRAINED_LIBRARIES
#define L_pack_df
#define L_unpack_df
#define L_pack_sf
#define L_unpack_sf
#define L_addsub_sf
#define L_addsub_df
#define L_mul_sf
#define L_mul_df
#define L_div_sf
#define L_div_df
#define L_fpcmp_parts_sf
#define L_fpcmp_parts_df
#define L_compare_sf
#define L_compare_df
#define L_eq_sf
#define L_eq_df
#define L_ne_sf
#define L_ne_df
#define L_gt_sf
#define L_gt_df
#define L_ge_sf
#define L_ge_df
#define L_lt_sf
#define L_lt_df
#define L_le_sf
#define L_le_df
#define L_si_to_sf
#define L_si_to_df
#define L_sf_to_si
#define L_df_to_si
#define L_f_to_usi
#define L_df_to_usi
#define L_negate_sf
#define L_negate_df
#define L_make_sf
#define L_make_df
#define L_sf_to_df
#define L_df_to_sf
#endif
#ifdef EXTENDED_FLOAT_STUBS
__truncxfsf2 (){ abort(); }
__extendsfxf2 (){ abort(); }
__addxf3 (){ abort(); }
__divxf3 (){ abort(); }
__eqxf2 (){ abort(); }
__extenddfxf2 (){ abort(); }
__gtxf2 (){ abort(); }
__lexf2 (){ abort(); }
__ltxf2 (){ abort(); }
__mulxf3 (){ abort(); }
__negxf2 (){ abort(); }
__nexf2 (){ abort(); }
__subxf3 (){ abort(); }
__truncxfdf2 (){ abort(); }
__trunctfsf2 (){ abort(); }
__extendsftf2 (){ abort(); }
__addtf3 (){ abort(); }
__divtf3 (){ abort(); }
__eqtf2 (){ abort(); }
__extenddftf2 (){ abort(); }
__gttf2 (){ abort(); }
__letf2 (){ abort(); }
__lttf2 (){ abort(); }
__multf3 (){ abort(); }
__negtf2 (){ abort(); }
__netf2 (){ abort(); }
__subtf3 (){ abort(); }
__trunctfdf2 (){ abort(); }
__gexf2 (){ abort(); }
__fixxfsi (){ abort(); }
__floatsixf (){ abort(); }
#else
typedef float SFtype __attribute__ ((mode (SF)));
typedef float DFtype __attribute__ ((mode (DF)));
typedef int HItype __attribute__ ((mode (HI)));
typedef int SItype __attribute__ ((mode (SI)));
typedef int DItype __attribute__ ((mode (DI)));
#ifndef CMPtype
#define CMPtype SItype
#endif
typedef unsigned int UHItype __attribute__ ((mode (HI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef unsigned int UDItype __attribute__ ((mode (DI)));
#define MAX_SI_INT ((SItype) ((unsigned) (~0)>>1))
#define MAX_USI_INT ((USItype) ~0)
#ifdef FLOAT_ONLY
#define NO_DI_MODE
#endif
#ifdef FLOAT
# define NGARDS 7L
# define GARDROUND 0x3f
# define GARDMASK 0x7f
# define GARDMSB 0x40
# define EXPBITS 8
# define EXPBIAS 127
# define FRACBITS 23
# define EXPMAX (0xff)
# define QUIET_NAN 0x100000L
# define FRAC_NBITS 32
# define FRACHIGH 0x80000000L
# define FRACHIGH2 0xc0000000L
# define pack_d __pack_f
# define unpack_d __unpack_f
# define __fpcmp_parts __fpcmp_parts_f
typedef USItype fractype;
typedef UHItype halffractype;
typedef SFtype FLO_type;
typedef SItype intfrac;
#else
# define PREFIXFPDP dp
# define PREFIXSFDF df
# define NGARDS 8L
# define GARDROUND 0x7f
# define GARDMASK 0xff
# define GARDMSB 0x80
# define EXPBITS 11
# define EXPBIAS 1023
# define FRACBITS 52
# define EXPMAX (0x7ff)
# define QUIET_NAN 0x8000000000000LL
# define FRAC_NBITS 64
# define FRACHIGH 0x8000000000000000LL
# define FRACHIGH2 0xc000000000000000LL
# define pack_d __pack_d
# define unpack_d __unpack_d
# define __fpcmp_parts __fpcmp_parts_d
typedef UDItype fractype;
typedef USItype halffractype;
typedef DFtype FLO_type;
typedef DItype intfrac;
#endif
#ifdef US_SOFTWARE_GOFAST
# ifdef FLOAT
# define add fpadd
# define sub fpsub
# define multiply fpmul
# define divide fpdiv
# define compare fpcmp
# define si_to_float sitofp
# define float_to_si fptosi
# define float_to_usi fptoui
# define negate __negsf2
# define sf_to_df fptodp
# define dptofp dptofp
#else
# define add dpadd
# define sub dpsub
# define multiply dpmul
# define divide dpdiv
# define compare dpcmp
# define si_to_float litodp
# define float_to_si dptoli
# define float_to_usi dptoul
# define negate __negdf2
# define df_to_sf dptofp
#endif
#else
# ifdef FLOAT
# define add __addsf3
# define sub __subsf3
# define multiply __mulsf3
# define divide __divsf3
# define compare __cmpsf2
# define _eq_f2 __eqsf2
# define _ne_f2 __nesf2
# define _gt_f2 __gtsf2
# define _ge_f2 __gesf2
# define _lt_f2 __ltsf2
# define _le_f2 __lesf2
# define si_to_float __floatsisf
# define float_to_si __fixsfsi
# define float_to_usi __fixunssfsi
# define negate __negsf2
# define sf_to_df __extendsfdf2
#else
# define add __adddf3
# define sub __subdf3
# define multiply __muldf3
# define divide __divdf3
# define compare __cmpdf2
# define _eq_f2 __eqdf2
# define _ne_f2 __nedf2
# define _gt_f2 __gtdf2
# define _ge_f2 __gedf2
# define _lt_f2 __ltdf2
# define _le_f2 __ledf2
# define si_to_float __floatsidf
# define float_to_si __fixdfsi
# define float_to_usi __fixunsdfsi
# define negate __negdf2
# define df_to_sf __truncdfsf2
# endif
#endif
#ifndef INLINE
#define INLINE __inline__
#endif
#define LSHIFT(a) { a = (a & 1) | (a >> 1); }
#define F_D_BITOFF (52+8-(23+7))
#define NORMAL_EXPMIN (-(EXPBIAS)+1)
#define IMPLICIT_1 (1LL<<(FRACBITS+NGARDS))
#define IMPLICIT_2 (1LL<<(FRACBITS+1+NGARDS))
typedef enum
{
CLASS_SNAN,
CLASS_QNAN,
CLASS_ZERO,
CLASS_NUMBER,
CLASS_INFINITY
} fp_class_type;
typedef struct
{
#ifdef SMALL_MACHINE
char class;
unsigned char sign;
short normal_exp;
#else
fp_class_type class;
unsigned int sign;
int normal_exp;
#endif
union
{
fractype ll;
halffractype l[2];
} fraction;
} fp_number_type;
typedef union
{
FLO_type value;
fractype value_raw;
#ifndef FLOAT
halffractype words[2];
#endif
#ifdef FLOAT_BIT_ORDER_MISMATCH
struct
{
fractype fraction:FRACBITS __attribute__ ((packed));
unsigned int exp:EXPBITS __attribute__ ((packed));
unsigned int sign:1 __attribute__ ((packed));
}
bits;
#endif
#ifdef _DEBUG_BITFLOAT
struct
{
unsigned int sign:1 __attribute__ ((packed));
unsigned int exp:EXPBITS __attribute__ ((packed));
fractype fraction:FRACBITS __attribute__ ((packed));
}
bits_big_endian;
struct
{
fractype fraction:FRACBITS __attribute__ ((packed));
unsigned int exp:EXPBITS __attribute__ ((packed));
unsigned int sign:1 __attribute__ ((packed));
}
bits_little_endian;
#endif
}
FLO_union_type;
#ifdef NO_NANS
#define nan() 0
#define isnan(x) 0
#define isinf(x) 0
#else
INLINE
static fp_number_type *
nan ()
{
static fp_number_type thenan;
return &thenan;
}
INLINE
static int
isnan ( fp_number_type * x)
{
return x->class == CLASS_SNAN || x->class == CLASS_QNAN;
}
INLINE
static int
isinf ( fp_number_type * x)
{
return x->class == CLASS_INFINITY;
}
#endif
INLINE
static int
iszero ( fp_number_type * x)
{
return x->class == CLASS_ZERO;
}
INLINE
static void
flip_sign ( fp_number_type * x)
{
x->sign = !x->sign;
}
extern FLO_type pack_d ( fp_number_type * );
#if defined(L_pack_df) || defined(L_pack_sf)
FLO_type
pack_d ( fp_number_type * src)
{
FLO_union_type dst;
fractype fraction = src->fraction.ll;
int sign = src->sign;
int exp = 0;
if (isnan (src))
{
exp = EXPMAX;
if (src->class == CLASS_QNAN || 1)
{
fraction |= QUIET_NAN;
}
}
else if (isinf (src))
{
exp = EXPMAX;
fraction = 0;
}
else if (iszero (src))
{
exp = 0;
fraction = 0;
}
else if (fraction == 0)
{
exp = 0;
}
else
{
if (src->normal_exp < NORMAL_EXPMIN)
{
int shift = NORMAL_EXPMIN - src->normal_exp;
exp = 0;
if (shift > FRAC_NBITS - NGARDS)
{
fraction = 0;
}
else
{
fraction >>= shift;
}
fraction >>= NGARDS;
}
else if (src->normal_exp > EXPBIAS)
{
exp = EXPMAX;
fraction = 0;
}
else
{
exp = src->normal_exp + EXPBIAS;
if ((fraction & GARDMASK) == GARDMSB)
{
if (fraction & (1 << NGARDS))
fraction += GARDROUND + 1;
}
else
{
fraction += GARDROUND;
}
if (fraction >= IMPLICIT_2)
{
fraction >>= 1;
exp += 1;
}
fraction >>= NGARDS;
}
}
#ifdef FLOAT_BIT_ORDER_MISMATCH
dst.bits.fraction = fraction;
dst.bits.exp = exp;
dst.bits.sign = sign;
#else
dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1);
dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS;
dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
#endif
#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
{
halffractype tmp = dst.words[0];
dst.words[0] = dst.words[1];
dst.words[1] = tmp;
}
#endif
return dst.value;
}
#endif
extern void unpack_d (FLO_union_type *, fp_number_type *);
#if defined(L_unpack_df) || defined(L_unpack_sf)
void
unpack_d (FLO_union_type * src, fp_number_type * dst)
{
fractype fraction;
int exp;
int sign;
#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
FLO_union_type swapped;
swapped.words[0] = src->words[1];
swapped.words[1] = src->words[0];
src = &swapped;
#endif
#ifdef FLOAT_BIT_ORDER_MISMATCH
fraction = src->bits.fraction;
exp = src->bits.exp;
sign = src->bits.sign;
#else
fraction = src->value_raw & ((((fractype)1) << FRACBITS) - (fractype)1);
exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
#endif
dst->sign = sign;
if (exp == 0)
{
if (fraction == 0)
{
dst->class = CLASS_ZERO;
}
else
{
dst->normal_exp = exp - EXPBIAS + 1;
fraction <<= NGARDS;
dst->class = CLASS_NUMBER;
#if 1
while (fraction < IMPLICIT_1)
{
fraction <<= 1;
dst->normal_exp--;
}
#endif
dst->fraction.ll = fraction;
}
}
else if (exp == EXPMAX)
{
if (fraction == 0)
{
dst->class = CLASS_INFINITY;
}
else
{
if (fraction & QUIET_NAN)
{
dst->class = CLASS_QNAN;
}
else
{
dst->class = CLASS_SNAN;
}
dst->fraction.ll = fraction;
}
}
else
{
dst->normal_exp = exp - EXPBIAS;
dst->class = CLASS_NUMBER;
dst->fraction.ll = (fraction << NGARDS) | IMPLICIT_1;
}
}
#endif
#if defined(L_addsub_sf) || defined(L_addsub_df)
static fp_number_type *
_fpadd_parts (fp_number_type * a,
fp_number_type * b,
fp_number_type * tmp)
{
intfrac tfraction;
int a_normal_exp;
int b_normal_exp;
fractype a_fraction;
fractype b_fraction;
if (isnan (a))
{
return a;
}
if (isnan (b))
{
return b;
}
if (isinf (a))
{
if (isinf (b) && a->sign != b->sign)
return nan ();
return a;
}
if (isinf (b))
{
return b;
}
if (iszero (b))
{
if (iszero (a))
{
*tmp = *a;
tmp->sign = a->sign & b->sign;
return tmp;
}
return a;
}
if (iszero (a))
{
return b;
}
{
int diff;
a_normal_exp = a->normal_exp;
b_normal_exp = b->normal_exp;
a_fraction = a->fraction.ll;
b_fraction = b->fraction.ll;
diff = a_normal_exp - b_normal_exp;
if (diff < 0)
diff = -diff;
if (diff < FRAC_NBITS)
{
while (a_normal_exp > b_normal_exp)
{
b_normal_exp++;
LSHIFT (b_fraction);
}
while (b_normal_exp > a_normal_exp)
{
a_normal_exp++;
LSHIFT (a_fraction);
}
}
else
{
if (a_normal_exp > b_normal_exp)
{
b_normal_exp = a_normal_exp;
b_fraction = 0;
}
else
{
a_normal_exp = b_normal_exp;
a_fraction = 0;
}
}
}
if (a->sign != b->sign)
{
if (a->sign)
{
tfraction = -a_fraction + b_fraction;
}
else
{
tfraction = a_fraction - b_fraction;
}
if (tfraction >= 0)
{
tmp->sign = 0;
tmp->normal_exp = a_normal_exp;
tmp->fraction.ll = tfraction;
}
else
{
tmp->sign = 1;
tmp->normal_exp = a_normal_exp;
tmp->fraction.ll = -tfraction;
}
while (tmp->fraction.ll < IMPLICIT_1 && tmp->fraction.ll)
{
tmp->fraction.ll <<= 1;
tmp->normal_exp--;
}
}
else
{
tmp->sign = a->sign;
tmp->normal_exp = a_normal_exp;
tmp->fraction.ll = a_fraction + b_fraction;
}
tmp->class = CLASS_NUMBER;
if (tmp->fraction.ll >= IMPLICIT_2)
{
LSHIFT (tmp->fraction.ll);
tmp->normal_exp++;
}
return tmp;
}
FLO_type
add (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
fp_number_type tmp;
fp_number_type *res;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
res = _fpadd_parts (&a, &b, &tmp);
return pack_d (res);
}
FLO_type
sub (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
fp_number_type tmp;
fp_number_type *res;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
b.sign ^= 1;
res = _fpadd_parts (&a, &b, &tmp);
return pack_d (res);
}
#endif
#if defined(L_mul_sf) || defined(L_mul_df)
static INLINE fp_number_type *
_fpmul_parts ( fp_number_type * a,
fp_number_type * b,
fp_number_type * tmp)
{
fractype low = 0;
fractype high = 0;
if (isnan (a))
{
a->sign = a->sign != b->sign;
return a;
}
if (isnan (b))
{
b->sign = a->sign != b->sign;
return b;
}
if (isinf (a))
{
if (iszero (b))
return nan ();
a->sign = a->sign != b->sign;
return a;
}
if (isinf (b))
{
if (iszero (a))
{
return nan ();
}
b->sign = a->sign != b->sign;
return b;
}
if (iszero (a))
{
a->sign = a->sign != b->sign;
return a;
}
if (iszero (b))
{
b->sign = a->sign != b->sign;
return b;
}
{
#if defined(NO_DI_MODE)
{
fractype x = a->fraction.ll;
fractype ylow = b->fraction.ll;
fractype yhigh = 0;
int bit;
for (bit = 0; bit < FRAC_NBITS; bit++)
{
int carry;
if (x & 1)
{
carry = (low += ylow) < ylow;
high += yhigh + carry;
}
yhigh <<= 1;
if (ylow & FRACHIGH)
{
yhigh |= 1;
}
ylow <<= 1;
x >>= 1;
}
}
#elif defined(FLOAT)
{
DItype answer = (DItype)(a->fraction.ll) * (DItype)(b->fraction.ll);
high = answer >> 32;
low = answer;
}
#else
{
UDItype nl = a->fraction.ll & 0xffffffff;
UDItype nh = a->fraction.ll >> 32;
UDItype ml = b->fraction.ll & 0xffffffff;
UDItype mh = b->fraction.ll >>32;
UDItype pp_ll = ml * nl;
UDItype pp_hl = mh * nl;
UDItype pp_lh = ml * nh;
UDItype pp_hh = mh * nh;
UDItype res2 = 0;
UDItype res0 = 0;
UDItype ps_hh__ = pp_hl + pp_lh;
if (ps_hh__ < pp_hl)
res2 += 0x100000000LL;
pp_hl = (ps_hh__ << 32) & 0xffffffff00000000LL;
res0 = pp_ll + pp_hl;
if (res0 < pp_ll)
res2++;
res2 += ((ps_hh__ >> 32) & 0xffffffffL) + pp_hh;
high = res2;
low = res0;
}
#endif
}
tmp->normal_exp = a->normal_exp + b->normal_exp;
tmp->sign = a->sign != b->sign;
#ifdef FLOAT
tmp->normal_exp += 2;
#else
tmp->normal_exp += 4;
#endif
while (high >= IMPLICIT_2)
{
tmp->normal_exp++;
if (high & 1)
{
low >>= 1;
low |= FRACHIGH;
}
high >>= 1;
}
while (high < IMPLICIT_1)
{
tmp->normal_exp--;
high <<= 1;
if (low & FRACHIGH)
high |= 1;
low <<= 1;
}
#if 0
if (low & FRACHIGH2)
{
if (((high & GARDMASK) != GARDMSB)
&& (((high + 1) & GARDMASK) == GARDMSB))
{
}
else
{
high++;
}
}
#endif
if ((high & GARDMASK) == GARDMSB)
{
if (high & (1 << NGARDS))
{
high += GARDROUND + 1;
}
else if (low)
{
high += GARDROUND + 1;
}
}
tmp->fraction.ll = high;
tmp->class = CLASS_NUMBER;
return tmp;
}
FLO_type
multiply (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
fp_number_type tmp;
fp_number_type *res;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
res = _fpmul_parts (&a, &b, &tmp);
return pack_d (res);
}
#endif
#if defined(L_div_sf) || defined(L_div_df)
static INLINE fp_number_type *
_fpdiv_parts (fp_number_type * a,
fp_number_type * b)
{
fractype bit;
fractype numerator;
fractype denominator;
fractype quotient;
if (isnan (a))
{
return a;
}
if (isnan (b))
{
return b;
}
a->sign = a->sign ^ b->sign;
if (isinf (a) || iszero (a))
{
if (a->class == b->class)
return nan ();
return a;
}
if (isinf (b))
{
a->fraction.ll = 0;
a->normal_exp = 0;
return a;
}
if (iszero (b))
{
a->class = CLASS_INFINITY;
return a;
}
{
a->normal_exp = a->normal_exp - b->normal_exp;
numerator = a->fraction.ll;
denominator = b->fraction.ll;
if (numerator < denominator)
{
numerator *= 2;
a->normal_exp--;
}
bit = IMPLICIT_1;
quotient = 0;
while (bit)
{
if (numerator >= denominator)
{
quotient |= bit;
numerator -= denominator;
}
bit >>= 1;
numerator *= 2;
}
if ((quotient & GARDMASK) == GARDMSB)
{
if (quotient & (1 << NGARDS))
{
quotient += GARDROUND + 1;
}
else if (numerator)
{
quotient += GARDROUND + 1;
}
}
a->fraction.ll = quotient;
return (a);
}
}
FLO_type
divide (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
fp_number_type *res;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
res = _fpdiv_parts (&a, &b);
return pack_d (res);
}
#endif
int __fpcmp_parts (fp_number_type * a, fp_number_type *b);
#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df)
int
__fpcmp_parts (fp_number_type * a, fp_number_type * b)
{
#if 0
if (isnan (a) && isnan (b))
{
return 1;
}
#endif
if (isnan (a) || isnan (b))
{
return 1;
}
if (isinf (a) && isinf (b))
{
return b->sign - a->sign;
}
if (isinf (a))
{
return a->sign ? -1 : 1;
}
if (isinf (b))
{
return b->sign ? 1 : -1;
}
if (iszero (a) && iszero (b))
{
return 0;
}
if (iszero (a))
{
return b->sign ? 1 : -1;
}
if (iszero (b))
{
return a->sign ? -1 : 1;
}
if (a->sign != b->sign)
{
return a->sign ? -1 : 1;
}
if (a->normal_exp > b->normal_exp)
{
return a->sign ? -1 : 1;
}
if (a->normal_exp < b->normal_exp)
{
return a->sign ? 1 : -1;
}
if (a->fraction.ll > b->fraction.ll)
{
return a->sign ? -1 : 1;
}
if (a->fraction.ll < b->fraction.ll)
{
return a->sign ? 1 : -1;
}
return 0;
}
#endif
#if defined(L_compare_sf) || defined(L_compare_df)
CMPtype
compare (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
return __fpcmp_parts (&a, &b);
}
#endif
#ifndef US_SOFTWARE_GOFAST
#if defined(L_eq_sf) || defined(L_eq_df)
CMPtype
_eq_f2 (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
if (isnan (&a) || isnan (&b))
return 1;
return __fpcmp_parts (&a, &b) ;
}
#endif
#if defined(L_ne_sf) || defined(L_ne_df)
CMPtype
_ne_f2 (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
if (isnan (&a) || isnan (&b))
return 1;
return __fpcmp_parts (&a, &b) ;
}
#endif
#if defined(L_gt_sf) || defined(L_gt_df)
CMPtype
_gt_f2 (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
if (isnan (&a) || isnan (&b))
return -1;
return __fpcmp_parts (&a, &b);
}
#endif
#if defined(L_ge_sf) || defined(L_ge_df)
CMPtype
_ge_f2 (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
if (isnan (&a) || isnan (&b))
return -1;
return __fpcmp_parts (&a, &b) ;
}
#endif
#if defined(L_lt_sf) || defined(L_lt_df)
CMPtype
_lt_f2 (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
if (isnan (&a) || isnan (&b))
return 1;
return __fpcmp_parts (&a, &b);
}
#endif
#if defined(L_le_sf) || defined(L_le_df)
CMPtype
_le_f2 (FLO_type arg_a, FLO_type arg_b)
{
fp_number_type a;
fp_number_type b;
unpack_d ((FLO_union_type *) & arg_a, &a);
unpack_d ((FLO_union_type *) & arg_b, &b);
if (isnan (&a) || isnan (&b))
return 1;
return __fpcmp_parts (&a, &b) ;
}
#endif
#endif
#if defined(L_si_to_sf) || defined(L_si_to_df)
FLO_type
si_to_float (SItype arg_a)
{
fp_number_type in;
in.class = CLASS_NUMBER;
in.sign = arg_a < 0;
if (!arg_a)
{
in.class = CLASS_ZERO;
}
else
{
in.normal_exp = FRACBITS + NGARDS;
if (in.sign)
{
if (arg_a == (SItype) 0x80000000)
{
return -2147483648.0;
}
in.fraction.ll = (-arg_a);
}
else
in.fraction.ll = arg_a;
while (in.fraction.ll < (1LL << (FRACBITS + NGARDS)))
{
in.fraction.ll <<= 1;
in.normal_exp -= 1;
}
}
return pack_d (&in);
}
#endif
#if defined(L_sf_to_si) || defined(L_df_to_si)
SItype
float_to_si (FLO_type arg_a)
{
fp_number_type a;
SItype tmp;
unpack_d ((FLO_union_type *) & arg_a, &a);
if (iszero (&a))
return 0;
if (isnan (&a))
return 0;
if (isinf (&a))
return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
if (a.normal_exp < 0)
return 0;
if (a.normal_exp > 30)
return a.sign ? (-MAX_SI_INT)-1 : MAX_SI_INT;
tmp = a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
return a.sign ? (-tmp) : (tmp);
}
#endif
#if defined(L_sf_to_usi) || defined(L_df_to_usi)
#ifdef US_SOFTWARE_GOFAST
USItype
float_to_usi (FLO_type arg_a)
{
fp_number_type a;
unpack_d ((FLO_union_type *) & arg_a, &a);
if (iszero (&a))
return 0;
if (isnan (&a))
return 0;
if (a.sign)
return 0;
if (isinf (&a))
return MAX_USI_INT;
if (a.normal_exp < 0)
return 0;
if (a.normal_exp > 31)
return MAX_USI_INT;
else if (a.normal_exp > (FRACBITS + NGARDS))
return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));
else
return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);
}
#endif
#endif
#if defined(L_negate_sf) || defined(L_negate_df)
FLO_type
negate (FLO_type arg_a)
{
fp_number_type a;
unpack_d ((FLO_union_type *) & arg_a, &a);
flip_sign (&a);
return pack_d (&a);
}
#endif
#ifdef FLOAT
#if defined(L_make_sf)
SFtype
__make_fp(fp_class_type class,
unsigned int sign,
int exp,
USItype frac)
{
fp_number_type in;
in.class = class;
in.sign = sign;
in.normal_exp = exp;
in.fraction.ll = frac;
return pack_d (&in);
}
#endif
#ifndef FLOAT_ONLY
extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype frac);
#if defined(L_sf_to_df)
DFtype
sf_to_df (SFtype arg_a)
{
fp_number_type in;
unpack_d ((FLO_union_type *) & arg_a, &in);
return __make_dp (in.class, in.sign, in.normal_exp,
((UDItype) in.fraction.ll) << F_D_BITOFF);
}
#endif
#endif
#endif
#ifndef FLOAT
extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);
#if defined(L_make_df)
DFtype
__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)
{
fp_number_type in;
in.class = class;
in.sign = sign;
in.normal_exp = exp;
in.fraction.ll = frac;
return pack_d (&in);
}
#endif
#if defined(L_df_to_sf)
SFtype
df_to_sf (DFtype arg_a)
{
fp_number_type in;
USItype sffrac;
unpack_d ((FLO_union_type *) & arg_a, &in);
sffrac = in.fraction.ll >> F_D_BITOFF;
if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)
sffrac |= 1;
return __make_fp (in.class, in.sign, in.normal_exp, sffrac);
}
#endif
#endif
#endif