int is_rectangle_inside (rectangle_t *rect, point_t *pt) { double half_w = rect->width / 2.0; double half_h = rect->height / 2.0; return (islessequal (rect->center.x - half_w, pt->x) && isgreaterequal (rect->center.x + half_w, pt->x) && islessequal (rect->center.y - half_h, pt->y) && isgreaterequal (rect->center.y + half_h, pt->y)); }
void test_islessequal() { static_assert((std::is_same<decltype(islessequal((float)0, (float)0)), bool>::value), ""); static_assert((std::is_same<decltype(islessequal((float)0, (double)0)), bool>::value), ""); static_assert((std::is_same<decltype(islessequal((float)0, (long double)0)), bool>::value), ""); static_assert((std::is_same<decltype(islessequal((double)0, (float)0)), bool>::value), ""); static_assert((std::is_same<decltype(islessequal((double)0, (double)0)), bool>::value), ""); static_assert((std::is_same<decltype(islessequal((double)0, (long double)0)), bool>::value), ""); static_assert((std::is_same<decltype(islessequal((long double)0, (float)0)), bool>::value), ""); static_assert((std::is_same<decltype(islessequal((long double)0, (double)0)), bool>::value), ""); static_assert((std::is_same<decltype(islessequal((long double)0, (long double)0)), bool>::value), ""); assert(islessequal(-1.0, 0.F) == true); }
/* wrapper yn */ double yn (int n, double x) { if (__builtin_expect (islessequal (x, 0.0) || isgreater (x, X_TLOSS), 0) && _LIB_VERSION != _IEEE_) { if (x < 0.0) { /* d = zero/(x-x) */ feraiseexcept (FE_INVALID); return __kernel_standard (n, x, 13); } else if (x == 0.0) { /* d = -one/(x-x) */ feraiseexcept (FE_DIVBYZERO); return __kernel_standard (n, x, 12); } else if (_LIB_VERSION != _POSIX_) /* yn(n,x>X_TLOSS) */ return __kernel_standard (n, x, 39); } return __ieee754_yn (n, x); }
/* wrapper y1f */ float y1f (float x) { if (__builtin_expect (islessequal (x, 0.0f) || isgreater (x, (float) X_TLOSS), 0) && _LIB_VERSION != _IEEE_) { if (x < 0.0f) { /* d = zero/(x-x) */ feraiseexcept (FE_INVALID); return __kernel_standard_f (x, x, 111); } else if (x == 0.0f) { /* d = -one/(x-x) */ feraiseexcept (FE_DIVBYZERO); return __kernel_standard_f (x, x, 110); } else if (_LIB_VERSION != _POSIX_) /* y1(x>X_TLOSS) */ return __kernel_standard_f (x, x, 137); } return __ieee754_y1f (x); }
/* wrapper y0l */ long double y0l (long double x) { # if defined(__UCLIBC_HAS_FENV__) if (__builtin_expect (islessequal (x, 0.0L) || isgreater (x, X_TLOSS), 0) && _LIB_VERSION != _IEEE_) { if (x < 0.0L) { /* d = zero/(x-x) */ feraiseexcept (FE_INVALID); return __kernel_standard_l (x, x, 209); } else if (x == 0.0L) { /* d = -one/(x-x) */ feraiseexcept (FE_DIVBYZERO); return __kernel_standard_l (x, x, 208); } else if (_LIB_VERSION != _POSIX_) /* y0(x>X_TLOSS) */ return __kernel_standard_l (x, x, 235); } # endif /* __UCLIBC_HAS_FENV__ */ return (long double)__ieee754_y0 ((double) x); }
double __fdim(double x, double y) { if (islessequal(x, y)) { x = 0.0; y = -x; } return (x - y); }
int is_rectangle_covered (rectangle_t *dest, rectangle_t *src) { double d_half_w = dest->width / 2.0; double d_half_h = dest->height / 2.0; double s_half_w = src->width / 2.0; double s_half_h = src->height / 2.0; return (islessequal (src->center.x - s_half_w, dest->center.x - d_half_w) && islessequal (src->center.y - s_half_h, dest->center.y - d_half_h) && isgreaterequal (src->center.x + s_half_w, dest->center.x + d_half_w) && isgreaterequal (src->center.y + s_half_h, dest->center.y + d_half_h)); }
void vtc_expect(struct vtclog *vl, const char *olhs, const char *lhs, const char *cmp, const char *orhs, const char *rhs) { vre_t *vre; const char *error; int erroroffset; int i, j, retval = -1; double fl, fr; j = lhs == NULL || rhs == NULL; if (lhs == NULL) lhs = "<undef>"; if (rhs == NULL) rhs = "<undef>"; if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { vre = VRE_compile(rhs, 0, &error, &erroroffset); if (vre == NULL) vtc_fatal(vl, "REGEXP error: %s (@%d) (%s)", error, erroroffset, rhs); i = VRE_exec(vre, lhs, strlen(lhs), 0, 0, NULL, 0, 0); retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); VRE_free(&vre); } else if (!strcmp(cmp, "==")) { retval = strcmp(lhs, rhs) == 0; } else if (!strcmp(cmp, "!=")) { retval = strcmp(lhs, rhs) != 0; } else if (j) { // fail inequality comparisons if either side is undef'ed retval = 0; } else { fl = VNUM(lhs); fr = VNUM(rhs); if (!strcmp(cmp, "<")) retval = isless(fl, fr); else if (!strcmp(cmp, ">")) retval = isgreater(fl, fr); else if (!strcmp(cmp, "<=")) retval = islessequal(fl, fr); else if (!strcmp(cmp, ">=")) retval = isgreaterequal(fl, fr); } if (retval == -1) vtc_fatal(vl, "EXPECT %s (%s) %s %s (%s) test not implemented", olhs, lhs, cmp, orhs, rhs); else if (retval == 0) vtc_fatal(vl, "EXPECT %s (%s) %s \"%s\" failed", olhs, lhs, cmp, rhs); else vtc_log(vl, 4, "EXPECT %s (%s) %s \"%s\" match", olhs, lhs, cmp, rhs); }
int main(){ int i; float n; for(i = 0; i < 100; i++) { scanf("%f", &n); if (islessequal(n, 10.0)) { printf("A[%d] = %.1f\n", i, n); } } }
long double __fdiml (long double x, long double y) { if (islessequal (x, y)) return 0.0f; long double r = x - y; if (isinf (r) && !isinf (x) && !isinf (y)) __set_errno (ERANGE); return r; }
FLOAT M_DECL_FUNC (__fdim) (FLOAT x, FLOAT y) { if (islessequal (x, y)) return 0; FLOAT r = math_narrow_eval (x - y); if (isinf (r) && !isinf (x) && !isinf (y)) __set_errno (ERANGE); return r; }
long double __fdiml(long double x, long double y) { #if defined(COMPARISON_MACRO_BUG) if (x == x && y == y && x <= y) { #else if (islessequal(x, y)) { #endif x = 0.0l; y = -x; } return (x - y); }
FLOAT M_DECL_FUNC (__fmin) (FLOAT x, FLOAT y) { if (islessequal (x, y)) return x; else if (isgreater (x, y)) return y; else if (issignaling (x) || issignaling (y)) return x + y; else return isnan (y) ? x : y; }
FLOAT M_DECL_FUNC (__w_log1p) (FLOAT x) { if (__glibc_unlikely (islessequal (x, M_LIT (-1.0)))) { if (x == -1) __set_errno (ERANGE); else __set_errno (EDOM); } return M_SUF (__log1p) (x); }
long double __w_log1pl (long double x) { if (__glibc_unlikely (islessequal (x, -1.0L))) { if (x == -1.0L) __set_errno (ERANGE); else __set_errno (EDOM); } return __log1pl (x); }
static int wave_generator_sinusoidal_open(struct sol_flow_node *node, void *data, const struct sol_flow_node_options *options) { struct drange_wave_generator_sinusoidal_data *mdata = data; const struct sol_flow_node_type_wave_generator_sinusoidal_options *opts = (const struct sol_flow_node_type_wave_generator_sinusoidal_options *)options; uint32_t tick_start; struct s_state *s_state; struct sol_drange *val; unsigned i; SOL_FLOW_NODE_OPTIONS_SUB_API_CHECK(opts, SOL_FLOW_NODE_TYPE_WAVE_GENERATOR_SINUSOIDAL_OPTIONS_API_VERSION, -EINVAL); if (islessequal(opts->amplitude.val, 0)) { SOL_ERR("Sinusoidal wave generator's multiplier must be greater " "than zero"); return -EDOM; } if (opts->ticks_per_period.val < 1) { SOL_ERR("Sinusoidal wave generator's ticks_per_period value (%d) cannot" " be less than 1)", opts->ticks_per_period.val); return -EDOM; } if (opts->tick_start.val < 0) { SOL_ERR("Sinusoidal wave generator's tick_start value (%d) cannot" " be less than 0)", opts->tick_start.val); return -EDOM; } mdata->amplitude = opts->amplitude.val; s_state = &mdata->s_state; val = &s_state->val; s_state->did_first = false; val->min = mdata->amplitude * -1.0; val->max = mdata->amplitude; mdata->rad_step = 2 * M_PI / opts->ticks_per_period.val; /* calculating starting val from tick_start */ val->val = 0; tick_start = opts->tick_start.val % opts->ticks_per_period.val; for (i = 0; i < tick_start; i++) sinusoidal_calc_next(mdata); return 0; }
void FLP32(void) { const double x = 0; const double y = 0; double result; result = acos(x); result = atan2(y, x); result = pow(x, y); if (((x == 0.f) && islessequal(y, 0)) || (isless(x, 0))) { /* handle domain and range errors */ } result = pow(x, y); result = sqrt(x); printf("%f", result); }
vector<double> GC_precon(SparseMatrix &M, SparseMatrix &A, vector<double> &b, int &iter, clock_t &clk) { vector<double> x, r, y, z, v, diag; int k, max = 2 * A.l_size(); double aux, tmp, s, m; SystemOpr solve; iter = 0; solve.setType(TRIANGULAR); clk = clock(); x.assign(A.l_size(), 0); diag = A.getDiagonal(); r = b; solve(M, v, modify(b, diag)); v = modify(v, diag); solve(M, y, modify(r, diag)); y = modify(y, diag); aux = y * r; for (k = 0; k < max; ++k) { z = A * v; s = aux / (v * z); x = x + s * v; r = r - s * z; tmp = (r * r); solve(M, y, modify(r, diag)); y = modify(y, diag); if (islessequal(tmp, TOL)) break; tmp = y * r; m = tmp / aux; aux = tmp; v = y + m * v; iter++; } clk = clock() - clk; return x; }
/* wrapper logf(x) */ float __logf (float x) { if (__builtin_expect (islessequal (x, 0.0f), 0) && _LIB_VERSION != _IEEE_) { if (x == 0.0f) { feraiseexcept (FE_DIVBYZERO); return __kernel_standard_f (x, x, 116); /* log(0) */ } else { feraiseexcept (FE_INVALID); return __kernel_standard_f (x, x, 117); /* log(x<0) */ } } return __ieee754_logf (x); }
/* wrapper log10(x) */ double __log10 (double x) { if (__builtin_expect (islessequal (x, 0.0), 0) && _LIB_VERSION != _IEEE_) { if (x == 0.0) { __feraiseexcept (FE_DIVBYZERO); return __kernel_standard (x, x, 18); /* log10(0) */ } else { __feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 19); /* log10(x<0) */ } } return __ieee754_log10 (x); }
/* wrapper log2l(x) */ long double __log2l (long double x) { if (__builtin_expect (islessequal (x, 0.0L), 0) && _LIB_VERSION != _IEEE_) { if (x == 0.0L) { feraiseexcept (FE_DIVBYZERO); return __kernel_standard_l (x, x, 248); /* log2(0) */ } else { feraiseexcept (FE_INVALID); return __kernel_standard_l (x, x, 249); /* log2(x<0) */ } } return __ieee754_log2l (x); }
/* wrapper log2f(x) */ float log2f (float x) { #if defined(__UCLIBC_HAS_FENV__) if (__builtin_expect (islessequal (x, 0.0f), 0) && _LIB_VERSION != _IEEE_) { if (x == 0.0) { feraiseexcept (FE_DIVBYZERO); return __kernel_standard_f (x, x, 148); /* log2(0) */ } else { feraiseexcept (FE_INVALID); return __kernel_standard_f (x, x, 149); /* log2(x<0) */ } } #endif return (float) __ieee754_log2 ((double) x); }
static int float_filter_process(struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet) { struct sol_drange value; int r; struct float_filter_data *mdata = data; r = sol_flow_packet_get_drange(packet, &value); SOL_INT_CHECK(r, < 0, r); if (isgreaterequal(value.val, mdata->min) && islessequal(value.val, mdata->max)) { if (mdata->range_override) { value.min = mdata->min; value.max = mdata->max; value.step = 1; } return sol_flow_send_drange_packet(node, SOL_FLOW_NODE_TYPE_FLOAT_FILTER__OUT__OUT, &value); } return 0; }
/* wrapper log(x) */ double log (double x) { #if defined(__UCLIBC_HAS_FENV__) if (__builtin_expect (islessequal (x, 0.0), 0) && _LIB_VERSION != _IEEE_) { if (x == 0.0) { feraiseexcept (FE_DIVBYZERO); return __kernel_standard (x, x, 16); /* log(0) */ } else { feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 17); /* log(x<0) */ } } #endif /* __UCLIBC_HAS_FENV__ */ return __ieee754_log (x); }
/* wrapper y0 */ double y0 (double x) { if (__builtin_expect (islessequal (x, 0.0) || isgreater (x, X_TLOSS), 0) && _LIB_VERSION != _IEEE_) { if (x < 0.0) { /* d = zero/(x-x) */ feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 9); } else if (x == 0.0) /* d = -one/(x-x) */ return __kernel_standard (x, x, 8); else if (_LIB_VERSION != _POSIX_) /* y0(x>X_TLOSS) */ return __kernel_standard (x, x, 35); } return __ieee754_y0 (x); }
double __fdim (double x, double y) { if (islessequal (x, y)) return 0.0; /* To avoid double rounding, set double precision for the subtraction. math_narrow_eval is still needed to eliminate excess range in the case of overflow. If the result of the subtraction is in the subnormal range for double, it is exact, so no issues of double rounding for subnormals arise. */ fpu_control_t cw, cw_double; _FPU_GETCW (cw); cw_double = (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW (cw_double); double r = math_narrow_eval (x - y); _FPU_SETCW (cw); if (isinf (r) && !isinf (x) && !isinf (y)) __set_errno (ERANGE); return r; }
/* wrapper y1l */ long double __y1l (long double x) { if (__builtin_expect (islessequal (x, 0.0L) || isgreater (x, X_TLOSS), 0) && _LIB_VERSION != _IEEE_) { if (x < 0.0L) { /* d = zero/(x-x) */ feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 211); } else if (x == 0.0L) /* d = -one/(x-x) */ return __kernel_standard (x, x, 210); else /* y1(x>X_TLOSS) */ return __kernel_standard (x, x, 237); } return __ieee754_y1l (x); }
double __fmin(double x, double y) { union { unsigned i[2]; double d; } xx, yy; unsigned s; /* if y is nan, replace it by x */ if (y != y) y = x; /* if x is greater than y or x and y are unordered, replace x by y */ #if defined(COMPARISON_MACRO_BUG) if (x != x || x > y) #else if (!islessequal(x, y)) #endif x = y; /* * now x and y are either both NaN or both numeric; set the * sign of the result if either x or y has its sign set */ xx.d = x; yy.d = y; #if defined(__sparc) s = (xx.i[0] | yy.i[0]) & 0x80000000; xx.i[0] |= s; #elif defined(__i386) s = (xx.i[1] | yy.i[1]) & 0x80000000; xx.i[1] |= s; #else #error Unknown architecture #endif return (xx.d); }
static int ln_process(struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet) { double value, result; int r; r = sol_flow_packet_get_drange_value(packet, &value); SOL_INT_CHECK(r, < 0, r); if (fpclassify(value) == FP_ZERO || islessequal(value, 0.0)) { SOL_WRN("Number can't be negative or too close to zero"); return -EDOM; } result = log(value); return sol_flow_send_drange_value_packet(node, SOL_FLOW_NODE_TYPE_FLOAT_LN__OUT__OUT, result); }
/* wrapper y0f */ float y0f (float x) { if (__builtin_expect (islessequal (x, 0.0f) || isgreater (x, (float) X_TLOSS), 0) && _LIB_VERSION != _IEEE_) { if (x < 0.0f) { /* d = zero/(x-x) */ feraiseexcept (FE_INVALID); return __kernel_standard_f (x, x, 109); } else if (x == 0.0f) /* d = -one/(x-x) */ return __kernel_standard_f (x, x, 108); else /* y0(x>X_TLOSS) */ return __kernel_standard_f (x, x, 135); } return __ieee754_y0f (x); }