Example #1
0
static long
internal_equality (long al, long ah, long bl, long bh, long neq)
{
  FP_DECL_EX;
  FP_DECL_Q(A); FP_DECL_Q(B);
  long r;

  FP_UNPACK_RAW_Q(A, a);
  FP_UNPACK_RAW_Q(B, b);

  if ((A_e == _FP_EXPMAX_Q && !_FP_FRAC_ZEROP_2(A))
       || (B_e == _FP_EXPMAX_Q && !_FP_FRAC_ZEROP_2(B)))
    {
      /* EQ and NE signal invalid operation only if either operand is SNaN.  */
      if (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B))
	{
	  FP_SET_EXCEPTION(FP_EX_INVALID);
	  FP_HANDLE_EXCEPTIONS;
	}
      return -1;
    }

  r = (A_e == B_e
       && _FP_FRAC_EQ_2 (A, B)
       && (A_s == B_s || (!A_e && _FP_FRAC_ZEROP_2(A))));
  r ^= neq;

  return r;
}
Example #2
0
CMPtype __unordtf2(TFtype a, TFtype b)
{
  FP_DECL_Q(A);
  FP_DECL_Q(B);
  CMPtype r;

  FP_UNPACK_RAW_Q(A, a);
  FP_UNPACK_RAW_Q(B, b);
  FP_CMP_UNORD_Q(r, A, B);

  return r;
}
Example #3
0
int _Q_flt(const long double a, const long double b)
{
  FP_DECL_EX;
  FP_DECL_Q(A); FP_DECL_Q(B);
  int r;

  FP_UNPACK_RAW_Q(A, a);
  FP_UNPACK_RAW_Q(B, b);
  FP_CMP_Q(r, B, A, 3, 2);
  FP_HANDLE_EXCEPTIONS;

  return (r == 1);
}
Example #4
0
int _Q_cmpe(const long double a, const long double b)
{
  FP_DECL_EX;
  FP_DECL_Q(A); FP_DECL_Q(B);
  int r;

  FP_UNPACK_RAW_Q(A, a);
  FP_UNPACK_RAW_Q(B, b);
  FP_CMP_Q(r, B, A, 3, 2);
  if (r == -1) r = 2;
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #5
0
int _Q_flt(const long double a, const long double b)
{
  FP_DECL_EX;
  FP_DECL_Q(A); FP_DECL_Q(B);
  int r;

  FP_UNPACK_RAW_Q(A, a);
  FP_UNPACK_RAW_Q(B, b);
  FP_CMP_Q(r, B, A, 3);
  if (r == 3)
    FP_SET_EXCEPTION(FP_EX_INVALID);
  FP_HANDLE_EXCEPTIONS;

  return (r == 1);
}
Example #6
0
int __eqtf2(TFtype a, TFtype b)
{
  FP_DECL_EX;
  FP_DECL_Q(A); FP_DECL_Q(B);
  int r;

  FP_UNPACK_RAW_Q(A, a);
  FP_UNPACK_RAW_Q(B, b);
  FP_CMP_EQ_Q(r, A, B);
  if (r && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
    FP_SET_EXCEPTION(FP_EX_INVALID);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #7
0
CMPtype __letf2(TFtype a, TFtype b)
{
  FP_DECL_EX;
  FP_DECL_Q(A); FP_DECL_Q(B);
  CMPtype r;

  FP_UNPACK_RAW_Q(A, a);
  FP_UNPACK_RAW_Q(B, b);
  FP_CMP_Q(r, A, B, 2);
  if (r == 2 && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
    FP_SET_EXCEPTION(FP_EX_INVALID);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #8
0
int _Q_fne(const long double a, const long double b)
{
  FP_DECL_EX;
  FP_DECL_Q(A); FP_DECL_Q(B);
  int r;

  FP_UNPACK_RAW_Q(A, a);
  FP_UNPACK_RAW_Q(B, b);
  FP_CMP_EQ_Q(r, A, B);
  if (r && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
    FP_SET_EXCEPTION(FP_EX_INVALID);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #9
0
CMPtype
__eqtf2 (TFtype a, TFtype b)
{
  FP_DECL_EX;
  FP_DECL_Q (A);
  FP_DECL_Q (B);
  CMPtype r;

  FP_INIT_EXCEPTIONS;
  FP_UNPACK_RAW_Q (A, a);
  FP_UNPACK_RAW_Q (B, b);
  FP_CMP_EQ_Q (r, A, B, 1);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #10
0
int _Q_cmp(const long double a, const long double b)
{
  FP_DECL_EX;
  FP_DECL_Q(A); FP_DECL_Q(B);
  int r;

  FP_UNPACK_RAW_Q(A, a);
  FP_UNPACK_RAW_Q(B, b);
  FP_CMP_Q(r, B, A, 3);
  if (r == -1) r = 2;
  if (r == 3 && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
    FP_SET_EXCEPTION(FP_EX_INVALID);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #11
0
DItype __fixtfdi(TFtype a)
{
  FP_DECL_EX;
  FP_DECL_Q(A);
  UDItype r;

  FP_UNPACK_RAW_Q(A, a);
  FP_TO_INT_Q(r, A, DI_BITS, 1);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
unsigned int _Q_qtou(const long double a)
{
  FP_DECL_EX;
  FP_DECL_Q(A);
  unsigned int r;

  FP_UNPACK_RAW_Q(A, a);
  FP_TO_INT_Q(r, A, 32, -1);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #13
0
USItype __fixunstfsi(TFtype a)
{
  FP_DECL_EX;
  FP_DECL_Q(A);
  USItype r;

  FP_UNPACK_RAW_Q(A, a);
  FP_TO_INT_Q(r, A, SI_BITS, 0);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #14
0
unsigned long long _Q_qtoull(const long double a)
{
  FP_DECL_EX;
  FP_DECL_Q(A);
  unsigned long long r;

  FP_UNPACK_RAW_Q(A, a);
  FP_TO_INT_Q(r, A, 64, -1);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #15
0
TFtype
__negtf2 (TFtype a)
{
  FP_DECL_Q (A);
  FP_DECL_Q (R);
  TFtype r;

  FP_UNPACK_RAW_Q (A, a);
  FP_NEG_Q (R, A);
  FP_PACK_RAW_Q (r, R);

  return r;
}
Example #16
0
TItype
__fixkfti (TFtype a)
{
  FP_DECL_EX;
  FP_DECL_Q (A);
  UTItype r;

  FP_INIT_EXCEPTIONS;
  FP_UNPACK_RAW_Q (A, a);
  FP_TO_INT_Q (r, A, TI_BITS, 1);
  FP_HANDLE_EXCEPTIONS;

  return r;
}
Example #17
0
int __ieee754_ilogbl (long double x)
{
  FP_DECL_EX;
  FP_DECL_Q(X);

/*
  FP_UNPACK_Q(X, x);
  switch (X_c)
    {
    case FP_CLS_ZERO:
      return FP_ILOGB0;
    case FP_CLS_NAN:
    case FP_CLS_INF:
      return FP_ILOGBNAN;
    default:
      return X_e;
    }
 */
  FP_UNPACK_RAW_Q(X, x);
  switch (X_e)
    {
    default:
      return X_e - _FP_EXPBIAS_Q;
    case 0:
#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
      if (_FP_FRAC_ZEROP_4(X))
	return FP_ILOGB0;
      else
	{
	  _FP_I_TYPE shift;
	  _FP_FRAC_CLZ_4(shift, X);
	  shift -= _FP_FRACXBITS_Q;
	  return X_e - _FP_EXPBIAS_Q - 1 + shift;
	}
#else
      if (_FP_FRAC_ZEROP_2(X))
	return FP_ILOGB0;
      else
	{
	  _FP_I_TYPE shift;
	  _FP_FRAC_CLZ_2(shift, X);
	  shift -= _FP_FRACXBITS_Q;
	  return X_e - _FP_EXPBIAS_Q - 1 + shift;
	}
#endif
    case _FP_EXPBIAS_Q:
      return FP_ILOGBNAN;
    }
}
Example #18
0
long double _Q_neg(const long double a)
{
  long double c = a;

#if (__BYTE_ORDER == __BIG_ENDIAN)
  ((UWtype *)&c)[0] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 64)
  ((UWtype *)&c)[1] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 32)
  ((UWtype *)&c)[3] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
#else
  FP_DECL_Q(A); FP_DECL_Q(C);

  FP_UNPACK_RAW_Q(A, a);
  FP_NEG_Q(C, A);
  FP_PACK_RAW_Q(c, C);
#endif
  return c;
}
Example #19
0
long
_OtsCvtXQ (long al, long ah, long _round)
{
  FP_DECL_EX;
  FP_DECL_Q(A);
  unsigned long r;
  long s;

  /* If bit 3 is set, then integer overflow detection is requested.  */
  s = _round & 8 ? 1 : -1;
  _round = _round & 3;

  FP_INIT_ROUNDMODE;
  FP_UNPACK_RAW_Q(A, a);
  FP_TO_INT_Q(r, A, 64, s);

  if (s > 0 && (_fex &= FP_EX_INVALID))
    FP_HANDLE_EXCEPTIONS;

  return r;
}