static int cs_modu_process(jack_nframes_t nframes, void *arg) { cs_modu_t *self = (cs_modu_t *) arg; float *in1_buffer = in1_buffer; /* suppress uninitialized warning */ float *in2_buffer = in2_buffer; /* suppress uninitialized warning */ float *out_buffer = (float *)jack_port_get_buffer(self->out_port, nframes); if(out_buffer == NULL) { return -1; } float in1 = atomic_float_read(&self->in1); if(isnanf(in1)) { in1_buffer = (float *)jack_port_get_buffer(self->in1_port, nframes); if(in1_buffer == NULL) { return -1; } } float in2 = atomic_float_read(&self->in2); if(isnanf(in2)) { in2_buffer = (float *)jack_port_get_buffer(self->in2_port, nframes); if(in2_buffer == NULL) { return -1; } } float in1_amp = atomic_float_read(&self->in1_amp); float in2_amp = atomic_float_read(&self->in2_amp); jack_nframes_t i; for(i = 0; i < nframes; i++) { out_buffer[i] = (isnanf(in1) ? in1_buffer[i] : in1) * (isnanf(in2) ? in2_buffer[i] : in2) * in1_amp * in2_amp; } return 0; }
bool GalleryScroll::onSwipe(const cocos2d::Vec2 &delta) { auto vec = _primary->getTexturePosition(); if (!isnan(vec.y)) { if (vec.y == 0.0f && delta.y > 0.0f) { onOverscrollBottom(delta.y); } if (vec.y == 1.0f && delta.y < 0.0f) { onOverscrollTop(delta.y); } } if (_hasPinch || _progress == 0.0f) { if (!_hasPinch) { if (delta.x > 0.0f && (isnanf(vec.x) || vec.x == 0.0f)) { onMove(delta.x); } else if (delta.x < 0.0f && (isnanf(vec.x) || vec.x == 1.0f)) { onMove(delta.x); } } return _primary->onSwipe(delta); } else { onMove(delta.x); return _primary->onSwipe(Vec2(0.0f, delta.y)); } }
int emulate_fcmpg(float value1, float value2) { if (isnanf(value1) || isnanf(value2)) return 1; return __emulate_fcmpx(value1, value2); }
static int cs_clock_process(jack_nframes_t nframes, void *arg) { cs_clock_t *self = (cs_clock_t *) arg; float *rate_buffer = rate_buffer; /* suppress uninitialized warning */ float *meter_buffer = meter_buffer; /* suppress uninitialized warning */ float *clock_buffer = (float *)jack_port_get_buffer(self->clock_port, nframes); if(clock_buffer == NULL) { return -1; } float meter = atomic_float_read(&self->meter); if(isnanf(meter)) { meter_buffer = (float *)jack_port_get_buffer(self->meter_port, nframes); if(meter_buffer == NULL) { return -1; } } float rate = atomic_float_read(&self->rate); if(isnanf(rate)) { rate_buffer = (float *)jack_port_get_buffer(self->rate_port, nframes); if(rate_buffer == NULL) { return -1; } } jack_nframes_t i; for(i = 0; i < nframes; i++) { double c_meter = isnanf(meter) ? meter_buffer[i] : meter; while(self->current >= c_meter) { self->current -= c_meter; } clock_buffer[i] = (float) self->current; self->current += (double) (isnanf(rate) ? rate_buffer[i] : rate); } return 0; }
void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames ) { for( int f = 0; f < frames; ++f ) { dst[f][0] += ( isinff( src[f][0] ) || isnanf( src[f][0] ) ) ? 0.0f : src[f][0] * coeffSrc * coeffSrcBuf->values()[f]; dst[f][1] += ( isinff( src[f][1] ) || isnanf( src[f][1] ) ) ? 0.0f : src[f][1] * coeffSrc * coeffSrcBuf->values()[f]; } }
/** * crank_box2_has_nan: * @box: A Box. * * Checks whether box has NaN. * * Returns: Whether box has NaN. */ gboolean crank_box2_has_nan (CrankBox2 *box) { return isnanf (box->start.x) || isnanf (box->start.y) || isnanf (box->end.x) || isnanf (box->end.y); }
float remainderf(float x, float y) { if (isnanf(x) || isnanf(y)) return (x * y); if (y == 0.0f || (*(int *) &x & ~0x80000000) == 0x7f800000) { /* y is 0 or x is infinite; raise invalid and return NaN */ y = 0.0f; *(int *) &x = 0x7f800000; return (x * y); } return ((float) remainder((double) x, (double) y)); }
void PlaneExtractor::CompareNormal(int x, int y, cl_float4* normalCloud, int planeID, int* countPixel){ //float Threshold = pointCloud[IMGIDX(y,x)].x; static const cl_int2 direction[] = {{-1,0},{1,0},{0,1},{0,-1}};//left, right, up, dwon if(planemap[IMGIDX(y,x)]==-1) { if(isnanf(normalCloud[y*IMAGE_WIDTH+x].x) || isnanf(normalCloud[y*IMAGE_WIDTH+x].y)) { planemap[IMGIDX(y,x)]=NotPlane; } else{ *countPixel = *countPixel + 1; planemap[IMGIDX(y,x)]=planeID; bool move[4] = {1,1,1,1}; bool move_twice[4] = {1,1,1,1}; if(x==0) move[0]=0; else if(x==1) move_twice[0]=0; if(x==IMAGE_WIDTH-1) move[1]=0; else if(x==IMAGE_WIDTH-2) move_twice[1]=0; if(y==IMAGE_HEIGHT-1) move[2]=0; else if(y==IMAGE_HEIGHT-2) move_twice[2]=0; if(y==0) move[3]=0; else if(y==1) move_twice[3]=0; for(int i=0; i<4; i++){ int x_move1 = x+direction[i].x; int y_move1 = y+direction[i].y; int x_move2 = x+direction[i].x*2; int y_move2 = y+direction[i].y*2; if(move[i] && clDot(normalCloud[IMGIDX(y,x)],normalCloud[IMGIDX(y_move1,x_move1)])>Threshold) { CompareNormal(x_move1, y_move1, normalCloud, planeID, countPixel); } else if(move_twice[i] && clDot(normalCloud[IMGIDX(y,x)],normalCloud[IMGIDX(y_move2,x_move2)])>Threshold) { CompareNormal(x_move1, y_move1, normalCloud, planeID, countPixel); CompareNormal(x_move2, y_move2, normalCloud, planeID, countPixel); } } } } }
int main () { /* Zero. */ ASSERT (ceilf (0.0f) == 0.0f); ASSERT (ceilf (-zero) == 0.0f); /* Positive numbers. */ ASSERT (ceilf (0.3f) == 1.0f); ASSERT (ceilf (0.7f) == 1.0f); ASSERT (ceilf (1.0f) == 1.0f); ASSERT (ceilf (1.001f) == 2.0f); ASSERT (ceilf (1.5f) == 2.0f); ASSERT (ceilf (1.999f) == 2.0f); ASSERT (ceilf (2.0f) == 2.0f); ASSERT (ceilf (65535.99f) == 65536.0f); ASSERT (ceilf (65536.0f) == 65536.0f); ASSERT (ceilf (2.341e31f) == 2.341e31f); /* Negative numbers. */ ASSERT (ceilf (-0.3f) == 0.0f); ASSERT (ceilf (-0.7f) == 0.0f); ASSERT (ceilf (-1.0f) == -1.0f); ASSERT (ceilf (-1.5f) == -1.0f); ASSERT (ceilf (-1.999f) == -1.0f); ASSERT (ceilf (-2.0f) == -2.0f); ASSERT (ceilf (-65535.99f) == -65535.0f); ASSERT (ceilf (-65536.0f) == -65536.0f); ASSERT (ceilf (-2.341e31f) == -2.341e31f); /* Infinite numbers. */ ASSERT (ceilf (1.0f / 0.0f) == 1.0f / 0.0f); ASSERT (ceilf (-1.0f / 0.0f) == -1.0f / 0.0f); /* NaNs. */ ASSERT (isnanf (ceilf (NaNf ()))); return 0; }
void get_map_extrema(const float * map, unsigned int nside, float * min, float * max) { size_t num_of_pixels = nside * nside * 12; const float * end_of_map = map + num_of_pixels; const float * cur_pixel = map; int is_first = 1; while(cur_pixel != end_of_map) { if(! isinff(*cur_pixel) && ! isnanf(*cur_pixel) && *cur_pixel > -1.6e+30) { if(! is_first) { if(*cur_pixel < *min) *min = *cur_pixel; else if(*cur_pixel > *max) *max = *cur_pixel; } else { *min = *max = *cur_pixel; is_first = 0; } } cur_pixel++; } }
float atan2f(float y, float x) /* wrapper atan2f */ { #ifdef _IEEE_LIBM return __ieee754_atan2f(y,x); #else float z; z = __ieee754_atan2f(y,x); if(_LIB_VERSION == _IEEE_||isnanf(x)||isnanf(y)) return z; if(x==(float)0.0&&y==(float)0.0) { /* atan2f(+-0,+-0) */ return (float)__kernel_standard((double)y,(double)x,103); } else return z; #endif }
int main () { /* See IEEE 754, section 6.3: "the sign of the result of the round floating-point number to integral value operation is the sign of the operand. These rules shall apply even when operands or results are zero or infinite." */ /* Zero. */ ASSERT (!signbit (truncf (0.0f))); ASSERT (!!signbit (truncf (minus_zerof)) == !!signbit (minus_zerof)); /* Positive numbers. */ ASSERT (!signbit (truncf (0.3f))); ASSERT (!signbit (truncf (0.7f))); /* Negative numbers. */ ASSERT (!!signbit (truncf (-0.3f)) == !!signbit (minus_zerof)); ASSERT (!!signbit (truncf (-0.7f)) == !!signbit (minus_zerof)); /* [MX] shaded specification in POSIX. */ /* NaN. */ ASSERT (isnanf (truncf (NaNf ()))); /* Infinity. */ ASSERT (truncf (Infinityf ()) == Infinityf ()); ASSERT (truncf (- Infinityf ()) == - Infinityf ()); return 0; }
int main () { /* Zero. */ ASSERT (truncf (0.0f) == 0.0f); ASSERT (truncf (minus_zerof) == 0.0f); /* Positive numbers. */ ASSERT (truncf (0.3f) == 0.0f); ASSERT (truncf (0.7f) == 0.0f); ASSERT (truncf (1.0f) == 1.0f); ASSERT (truncf (1.5f) == 1.0f); ASSERT (truncf (1.999f) == 1.0f); ASSERT (truncf (2.0f) == 2.0f); ASSERT (truncf (65535.99f) == 65535.0f); ASSERT (truncf (65536.0f) == 65536.0f); ASSERT (truncf (2.341e31f) == 2.341e31f); /* Negative numbers. */ ASSERT (truncf (-0.3f) == 0.0f); ASSERT (truncf (-0.7f) == 0.0f); ASSERT (truncf (-1.0f) == -1.0f); ASSERT (truncf (-1.5f) == -1.0f); ASSERT (truncf (-1.999f) == -1.0f); ASSERT (truncf (-2.0f) == -2.0f); ASSERT (truncf (-65535.99f) == -65535.0f); ASSERT (truncf (-65536.0f) == -65536.0f); ASSERT (truncf (-2.341e31f) == -2.341e31f); /* Infinite numbers. */ ASSERT (truncf (Infinityf ()) == Infinityf ()); ASSERT (truncf (- Infinityf ()) == - Infinityf ()); /* NaNs. */ ASSERT (isnanf (truncf (NaNf ()))); return 0; }
TEST(math, logbf) { ASSERT_EQ(-HUGE_VALF, logbf(0.0f)); ASSERT_TRUE(isnanf(logbf(nanf("")))); ASSERT_TRUE(__isinff(logbf(HUGE_VALF))); ASSERT_EQ(0.0f, logbf(1.0f)); ASSERT_EQ(3.0f, logbf(10.0f)); }
int gl_signbitf (float arg) { #if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT /* The use of a union to extract the bits of the representation of a 'long double' is safe in practice, despite of the "aliasing rules" of C99, because the GCC docs say "Even with '-fstrict-aliasing', type-punning is allowed, provided the memory is accessed through the union type." and similarly for other compilers. */ # define NWORDS \ ((sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) union { float value; unsigned int word[NWORDS]; } m; m.value = arg; return (m.word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; #elif HAVE_COPYSIGNF_IN_LIBC return copysignf (1.0f, arg) < 0; #else /* This does not do the right thing for NaN, but this is irrelevant for most use cases. */ if (isnanf (arg)) return 0; if (arg < 0.0f) return 1; else if (arg == 0.0f) { /* Distinguish 0.0f and -0.0f. */ static float plus_zero = 0.0f; float arg_mem = arg; return (memcmp (&plus_zero, &arg_mem, SIZEOF_FLT) != 0); } else return 0; #endif }
int mbbs_isnanf(float f) { #if defined(SOLARIS) || defined(IRIX) return isnanf(f); #else /* hope this works! */ return isnan((double)f); #endif /* defined(SOLARIS) || defined(IRIX) */ }
ATF_TC_BODY(powf_nan_y, tc) { #ifndef __vax__ const float y = 0.0L / 0.0L; ATF_CHECK(isnanf(powf(2.0, y)) != 0); #endif }
_M_INL float __ieee754_scalbf(float x, float fn) #endif { #ifdef _SCALB_INT return scalbnf(x,fn); #else if (isnanf(x)||isnanf(fn)) return x*fn; if (!finitef(fn)) { if(fn>(float)0.0) return x*fn; else return x/(-fn); } if (rintf(fn)!=fn) return (fn-fn)/(fn-fn); if ( fn > (float)65000.0) return scalbnf(x, 65000); if (-fn > (float)65000.0) return scalbnf(x,-65000); return scalbnf(x,(int)fn); #endif }
float asinhf(float x) { if (isnanf(x)) { return (x * x); /* + -> * for Cheetah */ } else { return ((float) asinh((double) x)); } }
ATF_TC_BODY(powf_nan_x, tc) { #ifndef __vax__ const float x = 0.0L / 0.0L; ATF_CHECK(isnanf(powf(x, 2.0)) != 0); #endif }
bool javaLangFloat_floatToIntBits(u4 arg0, u4 arg1, u4 arg2, u4 arg, JValue* pResult) { Convert32 convert; convert.arg = arg0; pResult->i = isnanf(convert.ff) ? 0x7fc00000 : arg0; return true; }
TEST(math, roundf) { fesetround(FE_TOWARDZERO); // roundf ignores the rounding mode and always rounds away from zero. ASSERT_FLOAT_EQ(1.0f, roundf(0.5f)); ASSERT_FLOAT_EQ(-1.0f, roundf(-0.5f)); ASSERT_FLOAT_EQ(0.0f, roundf(0.0f)); ASSERT_FLOAT_EQ(-0.0f, roundf(-0.0f)); ASSERT_TRUE(isnanf(roundf(nanf("")))); ASSERT_FLOAT_EQ(HUGE_VALF, roundf(HUGE_VALF)); }
float log2f(float x) { #if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN) if (isnanf(x)) return (x * x); else #endif return ((float) log2((double) x)); }
static int cs_bandpass_process(jack_nframes_t nframes, void *arg) { cs_bandpass_t *self = (cs_bandpass_t *) arg; float *in_buffer = in_buffer; /* suppress uninitialized warning */ float *freq_buffer = freq_buffer; /* suppress uninitialized warning */ float *Q_buffer = Q_buffer; /* suppress uninitialized warning */ float *out_buffer = (float *)jack_port_get_buffer(self->out_port, nframes); if(out_buffer == NULL) { return -1; } float in = atomic_float_read(&self->in); if(isnanf(in)) { in_buffer = (float *)jack_port_get_buffer(self->in_port, nframes); if(in_buffer == NULL) { return -1; } } float freq = atomic_float_read(&self->freq); if(isnanf(freq)) { freq_buffer = (float *)jack_port_get_buffer(self->freq_port, nframes); if(freq_buffer == NULL) { return -1; } } float Q = atomic_float_read(&self->Q); if(isnanf(Q)) { Q_buffer = (float *)jack_port_get_buffer(self->Q_port, nframes); if(Q_buffer == NULL) { return -1; } } float a = atomic_float_read(&self->atten); jack_nframes_t i; for(i = 0; i < nframes; i++) { double f = isnanf(freq) ? freq_buffer[i] : freq; if(f > 0.5) { f = 0.5; } double x = isnanf(in) ? in_buffer[i] : in; double w = 2.0 * M_PI * f; if(isnanf(a)) { a = sin(w)/(2*(isnanf(Q) ? Q_buffer[i] : Q)); } double y = (a/(1.0 + a)) * x - (a/(1.0 + a)) * self->x2 + (2*cos(w)/(1.0 + a)) * self->y1 - ((1 - a)/(1 + a)) * self->y2; self->x2 = self->x1; self->x1 = x; self->y2 = self->y1; if(y == INFINITY) { self->y1 = 1.0; } else if (y == -INFINITY) { self->y1 = -1.0; } else { self->y1 = y; } out_buffer[i] = y; } return 0; }
float lgammaf(float x) { float y; if (isnanf(x)) return (x * x); y = (float)__k_lgamma((double)x, &signgamf); signgam = signgamf; /* SUSv3 requires the setting of signgam */ return (y); }
int mr1_isnanf(float f) { #if defined(sparc_os5) || defined(IRIX) return isnanf(f); #else /* hope this works! */ return isnan((double) f); #endif /* defined(sparc_os5) || defined(IRIX) */ }
int float_eq(float x, float y) { int32_t ix0, iy0, ix, iy; if (isnanf(x) || isnanf(y)) return 0; ix = ix0 = *(int32_t *)&x; iy = iy0 = *(int32_t *)&y; if (ix < 0) { ix = -ix; if (!(iy0 < 0)) return 0; } if (iy < 0) { iy = -iy; if (!(ix0 < 0)) return 0; } return abs(ix - iy) <= kMaxUlps; }
float powf(float x, float y) /* wrapper powf */ { #ifdef _IEEE_LIBM return __ieee754_powf(x,y); #else float z; z=__ieee754_powf(x,y); if(_LIB_VERSION == _IEEE_|| isnanf(y)) return z; if(isnanf(x)) { if(y==(float)0.0) /* powf(NaN,0.0) */ return (float)__kernel_standard((double)x,(double)y,142); else return z; } if(x==(float)0.0){ if(y==(float)0.0) /* powf(0.0,0.0) */ return (float)__kernel_standard((double)x,(double)y,120); if(finitef(y)&&y<(float)0.0) /* powf(0.0,negative) */ return (float)__kernel_standard((double)x,(double)y,123); return z; } if(!finitef(z)) { if(finitef(x)&&finitef(y)) { if(isnanf(z)) /* powf neg**non-int */ return (float)__kernel_standard((double)x,(double)y,124); else /* powf overflow */ return (float)__kernel_standard((double)x,(double)y,121); } } if(z==(float)0.0&&finitef(x)&&finitef(y)) /* powf underflow */ return (float)__kernel_standard((double)x,(double)y,122); return z; #endif }
ATF_TC_BODY(strtof_nan, tc) { #ifndef __vax__ char *end; volatile float f = strtof(nan_string, &end); ATF_REQUIRE(isnanf(f) != 0); ATF_REQUIRE(strcmp(end, "y") == 0); #else atf_tc_skip("vax not supported"); #endif }
TEST(math, roundf) { auto guard = make_scope_guard([]() { fesetenv(FE_DFL_ENV); }); fesetround(FE_TOWARDZERO); // roundf ignores the rounding mode and always rounds away from zero. ASSERT_FLOAT_EQ(1.0f, roundf(0.5f)); ASSERT_FLOAT_EQ(-1.0f, roundf(-0.5f)); ASSERT_FLOAT_EQ(0.0f, roundf(0.0f)); ASSERT_FLOAT_EQ(-0.0f, roundf(-0.0f)); ASSERT_TRUE(isnanf(roundf(nanf("")))); ASSERT_FLOAT_EQ(HUGE_VALF, roundf(HUGE_VALF)); }