Exemple #1
0
int main(void) {
  float NaN = 0.0f / 0.0f;
  float Inf = 1.0f / 0.0f;
  float negInf = -1.0f / 0.0f;

  assert(floorf(2.9f) == 2.0f);

  float val = __VERIFIER_nondet_float();

  if (!__isnanf(val) && !__isinff(val) && !__iszerof(val)) {
    assert(floorf(val) <= val);
    assert(floorf(val) >= val - 1);
  }

  assert(floorf(0.0f) == 0.0f);
  assert(floorf(-0.0f) == -0.0f);
  int isNeg = __signbitf(floorf(-0.0f));
  assert(isNeg);

  assert(floorf(Inf) == Inf);
  assert(floorf(negInf) == negInf);

  assert(__isnanf(floorf(NaN)));

  return 0;
}
Exemple #2
0
/* wrapper remainderf */
float
__remainderf (float x, float y)
{
  if (((__builtin_expect (y == 0.0f, 0) && ! __isnanf (x))
       || (__builtin_expect (__isinf_nsf (x), 0) && ! __isnanf (y)))
      && _LIB_VERSION != _IEEE_)
    return __kernel_standard_f (x, y, 128); /* remainder domain */

  return __ieee754_remainderf (x, y);
}
Exemple #3
0
/* wrapper fmodf */
float
__fmodf (float x, float y)
{
  if (__builtin_expect (__isinf_nsf (x) || y == 0.0f, 0)
      && _LIB_VERSION != _IEEE_ && !__isnanf (y) && !__isnanf (x))
    /* fmod(+-Inf,y) or fmod(x,0) */
    return __kernel_standard_f (x, y, 127);

  return __ieee754_fmodf (x, y);
}
Exemple #4
0
/* wrapper powf */
float
__powf (float x, float y)
{
    float z = __ieee754_powf (x, y);
    if (__builtin_expect (!__finitef (z), 0))
    {
        if (_LIB_VERSION != _IEEE_)
        {
            if (__isnanf (x))
            {
                if (y == 0.0f)
                    /* pow(NaN,0.0) */
                    return __kernel_standard_f (x, y, 142);
            }
            else if (__finitef (x) && __finitef (y))
            {
                if (__isnanf (z))
                    /* pow neg**non-int */
                    return __kernel_standard_f (x, y, 124);
                else if (x == 0.0f && y < 0.0f)
                {
                    if (signbit (x) && signbit (z))
                        /* pow(-0.0,negative) */
                        return __kernel_standard_f (x, y, 123);
                    else
                        /* pow(+0.0,negative) */
                        return __kernel_standard_f (x, y, 143);
                }
                else
                    /* pow overflow */
                    return __kernel_standard_f (x, y, 121);
            }
        }
    }
    else if (__builtin_expect (z == 0.0f, 0) && __finitef (x) && __finitef (y)
             && _LIB_VERSION != _IEEE_)
    {
        if (x == 0.0f)
        {
            if (y == 0.0f)
                /* pow(0.0,0.0) */
                return __kernel_standard_f (x, y, 120);
        }
        else
            /* pow underflow */
            return __kernel_standard_f (x, y, 122);
    }

    return z;
}
Exemple #5
0
int main(void) {
  float NaN = 0.0f / 0.0f;
  float Inf = 1.0f / 0.0f;
  float negInf = -1.0f / 0.0f;

  float x = 2.0f;
  float y = -8.5;

  float a = 5.1;
  float b = -3.0f;
  float c = fmodf(a, b);
  assert(fabsf(c - 2.1) < 1e-8);

  if (!__isnanf(y)) {
    assert(__isnanf(fmodf(Inf, y)));
    assert(__isnanf(fmodf(negInf, y)));
  }

  if (!__isnanf(x)) {
    assert(__isnanf(fmodf(x, 0.0f)));
    assert(__isnanf(fmodf(x, -0.0f)));
  }

  
  if (!__isnanf(x) && !__isinff(x)) {
    assert(fmodf(x, Inf) == x);
    assert(fmodf(x, negInf) == x);
  }
 
  if (!__isnanf(y) && !__iszerof(y)) {
    assert(fmodf(0.0f, y) == 0.0f);
    assert(fmodf(-0.0f, y) == -0.0f);
    int isNeg = __signbitf(fmodf(-0.0f, y));
    assert(isNeg);
  }
 
  assert(__isnanf(fmodf(NaN, y)));
  assert(__isnanf(fmodf(x, NaN)));

  return 0;
}
Exemple #6
0
int main(void) {
  float NaN = 0.0f / 0.0f;
  float Inf = 1.0f / 0.0f;
  float negInf = -1.0f / 0.0f;

  float x = __VERIFIER_nondet_float();
  float y = __VERIFIER_nondet_float();

  if (!__isnanf(x) && !__isinff(x)) {
    if (!__isnanf(y) && !__isinff(y)) {
      float dim = fdimf(x, y);
      if (x > y) {
        assert(dim == x - y);
      } else {
        assert(dim == 0.0f);
      }
    }
  }

  if (!__isnanf(x)) {
    assert(fdimf(x, Inf) == 0.0f);
  }

  if (!__isnanf(y) && y < 0) {
    assert(fdimf(Inf, y) == Inf);
  }

  assert(__isnanf(fdimf(x, NaN)));
  assert(__isnanf(fdimf(NaN, y)));

  return 0;
}
Exemple #7
0
__complex__ float
__ccosf (__complex__ float x)
{
    __complex__ float res;

    if (!isfinite (__real__ x) || __isnanf (__imag__ x))
    {
        if (__real__ x == 0.0 || __imag__ x == 0.0)
        {
            __real__ res = __nanf ("");
            __imag__ res = 0.0;

#ifdef FE_INVALID
            if (__isinff (__real__ x))
                feraiseexcept (FE_INVALID);
#endif
        }
        else if (__isinff (__imag__ x))
        {
            __real__ res = HUGE_VALF;
            __imag__ res = __nanf ("");

#ifdef FE_INVALID
            if (__isinff (__real__ x))
                feraiseexcept (FE_INVALID);
#endif
        }
        else
        {
            __real__ res = __nanf ("");
            __imag__ res = __nanf ("");

#ifdef FE_INVALID
            if (isfinite (__imag__ x))
                feraiseexcept (FE_INVALID);
#endif
        }
    }
    else
    {
        __complex__ float y;

        __real__ y = -__imag__ x;
        __imag__ y = __real__ x;

        res = __ccoshf (y);
    }

    return res;
}
float
__log2f (float x)	/* wrapper log2f */
{
#ifdef _IEEE_LIBM
  return __ieee754_log2f (x);
#else
  float z;
  z = __ieee754_log2f (x);
  if (_LIB_VERSION == _IEEE_ || __isnanf (x)) return z;
  if (x <= 0.0f)
    {
      if (x == 0.0f)
	/* log2f (0) */
	return __kernel_standard ((double) x, (double) x, 148);
      else
	/* log2f (x < 0) */
	return __kernel_standard ((double) x, (double) x, 149);
    }
  else
    return z;
#endif
}
Exemple #9
0
int
__isnand (double x)
{
	return __isnanf((float) x);
}
TEST(math, __isnanf) {
  ASSERT_FALSE(__isnanf(123.0f));
  ASSERT_TRUE(__isnanf(nanf("")));
}