tgt::vec3 Flow3D::lookupFlowTrilinear(const tgt::vec3& r) const { tgt::ivec3 ir1(static_cast<int>(floorf(r.x)), static_cast<int>(floorf(r.y)), static_cast<int>(floorf(r.z))); ir1 = clampToFlowDimensions(ir1); tgt::ivec3 ir2 = clampToFlowDimensions(ir1 + tgt::ivec3(1)); // interpolate in x-direction // tgt::vec3 v1 = linearInterpolation(r.x, ir1, 0); tgt::vec3 v2 = linearInterpolation(r.x, tgt::ivec3(0, ir2.y, ir1.z), 0); tgt::vec3 v3 = linearInterpolation(r.x, tgt::ivec3(0, ir1.y, ir2.z), 0); tgt::vec3 v4 = linearInterpolation(r.x, ir2, 0); // interpolates value from x-direction interpolation in y-direction // float fintegral = 0.0f; float b = modff(r.y, &fintegral); float a = 1.0f - b; tgt::vec3 v5 = ((v1 * a) + (v2 * b)); tgt::vec3 v6 = ((v3 * a) + (v4 * b)); // interpolate values from y-direction interpolation in z-drection // b = modff(r.z, &fintegral); a = 1.0f - b; return ((v5 * a) + (v6 * b)); }
tgt::vec2 Flow2D::lookupFlowBilinear(const tgt::vec2& r) const { tgt::ivec2 irll = tgt::clamp(static_cast<tgt::ivec2>(r), tgt::ivec2::zero, dimensions_); tgt::ivec2 irlr = tgt::clamp(tgt::ivec2(irll.x + 1, irll.y), tgt::ivec2::zero, dimensions_); tgt::ivec2 irul = tgt::clamp(tgt::ivec2(irll.x, irll.y + 1), tgt::ivec2::zero, dimensions_); tgt::ivec2 irur = tgt::clamp(tgt::ivec2(irlr.x, irul.y), tgt::ivec2::zero, dimensions_); const tgt::vec2& vll = flow2D_[posToCellNumber(irll)]; const tgt::vec2& vlr = flow2D_[posToCellNumber(irlr)]; const tgt::vec2& vul = flow2D_[posToCellNumber(irul)]; const tgt::vec2& vur = flow2D_[posToCellNumber(irur)]; // interpolation in x-direction // float fintegral = 0.0f; float b = modff(r.x, &fintegral); float a = 1.0f - b; tgt::vec2 vl = vll * a + vlr * b; tgt::vec2 vu = vul * a + vur * b; // interpolation in y-direction // b = modff(r.y, &fintegral); a = 1.0f - b; return (vl * a + vu * b); }
/* ---------------------------------------------------------------------- * Variance calculation test * ------------------------------------------------------------------- */ int main(void) { arm_status status; float32_t mean; float32_t oneByBlockSize = 1.0 / (blockSize); float32_t variance; float32_t diff; status = ARM_MATH_SUCCESS; puts("ARM DSP lib test"); puts("Note: This test is using 32 bit IEEE 754 floating point numbers," "(24 bit mantissa, 7 bit exponent)"); puts("Expect roughly 7 decimals precision on the result."); /* Calculation of mean value of input */ /* x' = 1/blockSize * (x(0)* 1 + x(1) * 1 + ... + x(n-1) * 1) */ /* Fill wire1 buffer with 1.0 value */ arm_fill_f32(1.0, wire1, blockSize); /* Calculate the dot product of wire1 and wire2 */ /* (x(0)* 1 + x(1) * 1 + ...+ x(n-1) * 1) */ arm_dot_prod_f32(testInput_f32, wire1, blockSize, &mean); /* 1/blockSize * (x(0)* 1 + x(1) * 1 + ... + x(n-1) * 1) */ arm_mult_f32(&mean, &oneByBlockSize, &mean, 1); /* Calculation of variance value of input */ /* (1/blockSize) * (x(0) - x') * (x(0) - x') + (x(1) - x') * (x(1) - x') + ... + (x(n-1) - x') * (x(n-1) - x') */ /* Fill wire2 with mean value x' */ arm_fill_f32(mean, wire2, blockSize); /* wire3 contains (x-x') */ arm_sub_f32(testInput_f32, wire2, wire3, blockSize); /* wire2 contains (x-x') */ arm_copy_f32(wire3, wire2, blockSize); /* (x(0) - x') * (x(0) - x') + (x(1) - x') * (x(1) - x') + ... + (x(n-1) - x') * (x(n-1) - x') */ arm_dot_prod_f32(wire2, wire3, blockSize, &variance); /* Calculation of 1/blockSize */ oneByBlockSize = 1.0 / (blockSize - 1); /* Calculation of variance */ arm_mult_f32(&variance, &oneByBlockSize, &variance, 1); /* absolute value of difference between ref and test */ diff = variance - refVarianceOut; /* Split into fractional and integral parts, since printing floats may not be supported on all platforms */ float int_part; float frac_part = fabsf(modff(variance, &int_part)); printf(" dsp: %3d.%09d\n", (int) int_part, (int) (frac_part * 1.0e9f + 0.5f)); puts( "reference: 0.903941793931839"); frac_part = fabsf(modff(diff, &int_part)); printf(" diff: %3d.%09d\n", (int) int_part, (int) (frac_part * 1.0e9f + 0.5f)); /* Comparison of variance value with reference */ if(fabsf(diff) > DELTA) { status = ARM_MATH_TEST_FAILURE; } if(status != ARM_MATH_SUCCESS) { puts("Test failed"); while(1) ; } puts("Test done"); while(1) ; /* main function does not return */ }
void sht11_display_data(SHT11_t *structure) { #ifndef _TINY_PRINT_ UARTprintf(DebugCom, "SHT11: T = %2.2f, H = %2.3f\n\r", structure->temperature, structure->humidity); #else float Temp; float FractTemp = modff(structure->temperature, &Temp) * 1000; float Hum; float FractHum = modff(structure->humidity, &Hum) * 1000; UARTprintf(DebugCom, "SHT11: T = %d.%d, H = %d.%d\n\r", (signed long)Temp, (signed long)FractTemp, (signed long)Hum, (signed long)FractHum); #endif }
static bool CountBeat(FrameT *frame) { static int lastFrame = 0; float lf = lastFrame / DemoBeat; float tf = frame->number / DemoBeat; float li, ti; lf = modff(lf, &li); tf = modff(tf, &ti); lastFrame = frame->number; return li < ti; }
float SwingTwistConstraint::SwingLimitFunction::getMinDot(float theta) const { // extract the positive normalized fractional part of theta float integerPart; float normalizedTheta = modff(theta / TWO_PI, &integerPart); if (normalizedTheta < 0.0f) { normalizedTheta += 1.0f; } // interpolate between the two nearest points in the cycle float fractionPart = modff(normalizedTheta * (float)(_minDots.size() - 1), &integerPart); int i = (int)(integerPart); int j = (i + 1) % _minDots.size(); return _minDots[i] * (1.0f - fractionPart) + _minDots[j] * fractionPart; }
inline void Flow2D::BackTrace(Int2 Plaquette[2], float Weights[4], const int index) { int iX = index % m_Nx; int iY = index / m_Nx; int indexFull = GetIndexFull(iX, iY); float fBackPtX = float(iX) - m_TmpVel.x.aligned[indexFull] * m_dtime; float fBackPtY = float(iY) - m_TmpVel.y.aligned[indexFull] * m_dtime; if (fBackPtX < 0.0f) { fBackPtX = m_Nx-1 + fmodf(fBackPtX, (float)m_Nx); } else if (fBackPtX >= m_Nx) { fBackPtX = fmodf(fBackPtX, (float)m_Nx); } if (fBackPtY < 0.0f) { fBackPtY = m_Ny-1 + fmodf(fBackPtY, (float)m_Ny); } else if (fBackPtY >= m_Ny) { fBackPtY = fmodf(fBackPtY, (float)m_Ny); } float fdx,fdy; float fidx, fidy; fdx = modff(fBackPtX ,&(fidx)); fdy = modff(fBackPtY, &(fidy)); // Set Sites Co On A Plaquette Plaquette[0].x = (int)fidx; Plaquette[0].y = (int)fidy; //right if (Plaquette[0].x == m_Nx - 1) { Plaquette[1].x = 0; } else { Plaquette[1].x = Plaquette[0].x+ 1; } //top if (Plaquette[0].y == m_Ny - 1) { Plaquette[1].y = 0; } else { Plaquette[1].y = Plaquette[0].y + 1; } Weights[3] = fdx * fdy; Weights[2] = fdy - Weights[3]; Weights[1] = fdx - Weights[3]; Weights[0] = 1.0f - Weights[1] - fdy; }
QString StaticHelpers::toKbMbGb(size_type size, bool isSpped) { float val = size; char* SizeSuffix[] = { QT_TRANSLATE_NOOP("Torrent", " B"), QT_TRANSLATE_NOOP("Torrent", " Kb"), QT_TRANSLATE_NOOP("Torrent", " Mb"), QT_TRANSLATE_NOOP("Torrent", " Gb"), QT_TRANSLATE_NOOP("Torrent", " Tb"), QT_TRANSLATE_NOOP("Torrent", " Pb"), QT_TRANSLATE_NOOP("Torrent", " Eb"), QT_TRANSLATE_NOOP("Torrent", " Zb") }; char* SpeedSuffix[] = { QT_TRANSLATE_NOOP("Torrent", " B\\s"), QT_TRANSLATE_NOOP("Torrent", " Kb\\s"), QT_TRANSLATE_NOOP("Torrent", " Mb\\s"), QT_TRANSLATE_NOOP("Torrent", " Gb\\s"), QT_TRANSLATE_NOOP("Torrent", " Tb\\s"), QT_TRANSLATE_NOOP("Torrent", " Pb\\s"), QT_TRANSLATE_NOOP("Torrent", " Eb\\s"), QT_TRANSLATE_NOOP("Torrent", " Zb\\s") }; int i = 0; float dblSByte = val; if (size > KbInt) { for (i; size_type(val / KbInt) > 0; i++, val /= KbInt) { dblSByte = val / KbFloat; } } float fractpart, intpart; fractpart = modff(dblSByte, &intpart); QString str; if (fractpart < FLT_EPSILON) { str = QString::number(int(dblSByte)); } else { str = QString::number(dblSByte, 'f', i == 0 ? 0 : 2); } if (isSpped) { str.append(qApp->translate("Torrent", SpeedSuffix[i])); } else { str.append(qApp->translate("Torrent", SizeSuffix[i])); } return str; }
float LinInterpolateRampU16 ( unsigned short * ramp, int ramp_size, float pos ) { unsigned short val1, val2; float start, dist, result; if(!ramp) return 0.0; if(pos < 0) return ramp[0]; if(pos > ramp_size-1) return ramp[ramp_size-1]; dist = modff( pos, &start ); val1 = ramp[(int)start]; val2 = ramp[(int)start+1]; result = val2 - val1; result *= dist; result += val1; return result; }
//---------------------------------------------------------------------- // configInit //---------------------------------------------------------------------- bool Window::configInit( const uint128_t& initID ) { if( !getPixelViewport().isValid( )) { sendError( ERROR_WINDOW_PVP_INVALID ); return false; } LBASSERT( !_systemWindow ); int glMajorVersion = 1; int glMinorVersion = 1; if( getPipe()->getSystemPipe()->getMaxOpenGLVersion() != AUTO ) { float maj, min; min = modff( getPipe()->getSystemPipe()->getMaxOpenGLVersion(), &maj ); glMajorVersion = static_cast< int >( maj ); glMinorVersion = static_cast< int >( min*10.f ); } if( getIAttribute( WindowSettings::IATTR_HINT_OPENGL_MAJOR ) == AUTO ) setIAttribute( WindowSettings::IATTR_HINT_OPENGL_MAJOR, glMajorVersion); if( getIAttribute( WindowSettings::IATTR_HINT_OPENGL_MINOR ) == AUTO ) setIAttribute( WindowSettings::IATTR_HINT_OPENGL_MINOR, glMinorVersion); return configInitSystemWindow( initID ) && configInitGL( initID ); }
MPI_Point2D MPI_ParticleStroke::linearPositionToPoint( float position ) const { // go from a linear position along the stroke in canonical coordinates // (where breakpoints corresponsd to successive integer coords) to // 2d space coordinates. linearly interpolate between breakpoints // for fractional positions. // assumes 0.0 <= position <= pointList_.size()-1 // if it's the last index, return the last point // otherwise, interpolate between current point and the next one float integerpart; float fractionalpart = modff( position, &integerpart ); unsigned int firstindex = static_cast<unsigned int>( integerpart ); unsigned int secondindex = static_cast<unsigned int>( integerpart+1.0 ); // if we're after the last point, just return it if ( firstindex == pointList_.size()-1 ) return pointList_[firstindex]->getPoint(); // interpolate between the first and second points MPI_Point2D const& firstpoint = pointList_[firstindex]->getPoint(); MPI_Point2D const& secondpoint = pointList_[secondindex]->getPoint(); return MPI_Point2D( (1.0-fractionalpart)*firstpoint.getX() + fractionalpart*secondpoint.getX(), (1.0-fractionalpart)*firstpoint.getY() + fractionalpart*secondpoint.getY() ); }
static void runAddingModDelay(LADSPA_Handle instance, unsigned long sample_count) { ModDelay *plugin_data = (ModDelay *)instance; LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Base delay (s) (float value) */ const LADSPA_Data base = *(plugin_data->base); /* Delay (s) (array of floats of length sample_count) */ const LADSPA_Data * const delay = plugin_data->delay; /* Input (array of floats of length sample_count) */ const LADSPA_Data * const input = plugin_data->input; /* Output (array of floats of length sample_count) */ LADSPA_Data * const output = plugin_data->output; LADSPA_Data * buffer = plugin_data->buffer; unsigned int buffer_mask = plugin_data->buffer_mask; float fs = plugin_data->fs; unsigned int write_ptr = plugin_data->write_ptr; #line 42 "mod_delay_1419.xml" unsigned long pos; for (pos = 0; pos < sample_count; pos++) { float tmp; const float rpf = modff((base + delay[pos]) * fs, &tmp); const int rp = write_ptr - 4 - f_round(tmp); buffer[write_ptr++] = input[pos]; write_ptr &= buffer_mask; buffer_write(output[pos], cube_interp(rpf, buffer[(rp - 1) & buffer_mask], buffer[rp & buffer_mask], buffer[(rp + 1) & buffer_mask], buffer[(rp + 2) & buffer_mask])); } plugin_data->write_ptr = write_ptr; }
/***** * voltstostrng() - converts volts to a fixed format string * * accepts an float voltage reading and turns it into a 5 character string * of the following format: * (+/-)x.yy * where (+/-) is the sign, x is the integer part of the voltage and yy is * the decimal part of the voltage. * * NOTE: Assumes that s points to an array of at least 6 bytes. *****/ void voltstostrng(float v, char* s) { float dpf, ipf; u32 dpi; u32 ones, tenths, hundredths; // form the fixed digits dpf = modff(v, &ipf); dpi = dpf * 100; ones = abs(ipf) + '0'; tenths = (dpi / 10) + '0'; hundredths = (dpi - ((tenths - '0') * 10)) + '0'; // form the string and return if (ipf == 0 && dpf == 0) { *s++ = ' '; } else { *s++ = ipf >= 0 ? '+' : '-'; } *s++ = (char) ones; *s++ = '.'; *s++ = (char) tenths; *s++ = (char) hundredths; *s = 0; return; };
int main(void) { float f = 123.45; float f3; float f2 = modff(f, &f3); __VERIFIER_assert(f3 == 123.f); __VERIFIER_assert(f2 == 0x1.ccccp-2); float param, fractpart, intpart; param = 3.14159265; fractpart = modff(param , &intpart); __VERIFIER_assert(intpart == 3.f); __VERIFIER_assert(fractpart == 0x1.21fb6p-3); }
// Get's the value the slider is current positioned at //-------------------------------------------------------------------------------- CPUTResult CPUTSlider::GetValue(float & fValue) { LocationGuides guides; CalculateLocationGuides(guides); float fractpart, intpart; fractpart = modff((mSliderNubLocation/guides.StepSpacing) , &intpart); int index = (int) intpart; if(fractpart>=0.5f) index++; float stepSizeValue = (mSliderEndValue - mSliderStartValue)/(float)(mSliderNumberOfSteps-1); // calculate the slider location's value fValue = mSliderStartValue + stepSizeValue*index; // In extreme range cases, the calculated value might be off by a fractional amount // prevent the slider from returning an above/below start/end value if(fValue > mSliderEndValue) { fValue = mSliderEndValue; } if(fValue < mSliderStartValue) { fValue = mSliderStartValue; } return CPUT_SUCCESS; }
/* conversion function to 1.NUMBER_OF_BITS format */ int convert(float value) { float man, t_val, frac, m, exponent = NUMBER_OF_BITS; int rnd_val; unsigned long int_val; unsigned long pm_val; m = exp2f(exponent+1) - 1; t_val = value * m ; frac = modff(t_val,&man); if (frac < 0.0f) { rnd_val = (-1); if (frac > -0.5f) rnd_val = 0; } else { rnd_val = 1; if (frac < 0.5f) rnd_val = 0; } int_val = man + rnd_val; pm_val = int_val ; return ((int) (pm_val)) ; }
static void _cogl_texture_iter_update (CoglTextureIter *iter) { float t_2; float frac_part; frac_part = modff (iter->pos, &iter->next_pos); /* modff rounds the int part towards zero so we need to add one if we're meant to be heading away from zero */ if (iter->pos >= 0.0f || frac_part == 0.0f) iter->next_pos += 1.0f; if (iter->next_pos > iter->end) t_2 = iter->end; else t_2 = iter->next_pos; if (iter->flipped) { iter->t_1 = t_2; iter->t_2 = iter->pos; } else { iter->t_1 = iter->pos; iter->t_2 = t_2; } }
void upsampleArray( const pfs::Array2D *in, pfs::Array2D *out, ResampleFilter *filter ) { float dx = (float)in->getCols() / (float)out->getCols(); float dy = (float)in->getRows() / (float)out->getRows(); float pad; float filterSamplingX = max( modff( dx, &pad ), 0.01f ); float filterSamplingY = max( modff( dy, &pad ), 0.01f ); const int outRows = out->getRows(); const int outCols = out->getCols(); const float inRows = (float)in->getRows(); const float inCols = (float)in->getCols(); const float filterSize = filter->getSize(); // TODO: possible optimization: create lookup table for the filter float sx, sy; int x, y; for( y = 0, sy = -0.5f + dy/2; y < outRows; y++, sy += dy ) for( x = 0, sx = -0.5f + dx/2; x < outCols; x++, sx += dx ) { float pixVal = 0; float weight = 0; for( float ix = max( 0, ceilf( sx-filterSize ) ); ix <= min( floorf(sx+filterSize), inCols-1 ); ix++ ) for( float iy = max( 0, ceilf( sy-filterSize ) ); iy <= min( floorf( sy+filterSize), inRows-1 ); iy++ ) { float fx = fabs( sx - ix ); float fy = fabs( sy - iy ); const float fval = filter->getValue( fx )*filter->getValue( fy ); pixVal += (*in)( (int)ix, (int)iy ) * fval; weight += fval; } if( weight == 0 ) { fprintf( stderr, "%g %g %g %g\n", sx, sy, dx, dy ); } // assert( weight != 0 ); (*out)(x,y) = pixVal / weight; } }
bool ms5611_display_pressure_result(MS5611_t *structure, unsigned char osr) { signed int Preasure = 0; signed int Temperature = 0; //if(!ms5611_read_prom_cmd_send(prom_data, TwiStruct)) return false; if(!ms5611_read(structure, osr, &Preasure, &Temperature)) return false; #ifndef _TINY_PRINT_ UARTprintf(DebugCom, "MS5611:\n\rP = %4.2f milibar, T = %2.2f gr celsius\n\r", ((float)Preasure) / 100.0, ((float)Temperature) / 100.0); #else float PreasureInt = 0; float PreasureDec = modff(((float)Preasure)/100.0, &PreasureInt); float TemperatureInt = 0; float TemperatureDec = modff(((float)Preasure)/100.0, &Temperature); UARTprintf(DebugCom, "MS5611:\n\rP = %d.%u milibar, T = %d.%u gr celsius\n\r", (signed int)PreasureInt, (unsigned int)(PreasureDec * 100.0), (signed int)TemperatureInt, (unsigned int)(TemperatureDec * 100.0)); #endif return true; }
void test_modf() { static_assert((std::is_same<decltype(modf((double)0, (double*)0)), double>::value), ""); static_assert((std::is_same<decltype(modff(0, (float*)0)), float>::value), ""); static_assert((std::is_same<decltype(modfl(0, (long double*)0)), long double>::value), ""); double i; assert(modf(1., &i) == 0); }
int main(void) { hih6130_t dev; puts("HIH6130 sensor driver test application\n"); printf("Initializing I2C_%i... ", TEST_HIH6130_I2C); if (i2c_init_master(TEST_HIH6130_I2C, I2C_SPEED_FAST) < 0) { puts("[Failed]"); return -1; } puts("[OK]"); printf("Initializing HIH6130 sensor at I2C_%i, address 0x%02x... ", TEST_HIH6130_I2C, TEST_HIH6130_ADDR); hih6130_init(&dev, TEST_HIH6130_I2C, TEST_HIH6130_ADDR); puts("[OK]"); while (1) { float hum = 0.f; float temp = 0.f; int status; float integral = 0.f; float fractional; vtimer_usleep(SLEEP); status = hih6130_get_humidity_temperature_float(&dev, &hum, &temp); if (status < 0) { printf("Communication error: %d\n", status); continue; } else if (status == 1) { puts("Stale values"); } /* Several platforms usually build with nano.specs, (without float printf) */ /* Split value into two integer parts for printing. */ fractional = modff(hum, &integral); printf("humidity: %4d.%04u %%", (int)integral, (unsigned int)abs(fractional * 10000.f)); fractional = modff(temp, &integral); printf(" temperature: %4d.%04u C\n", (int)integral, (unsigned int)abs(fractional * 10000.f)); } return 0; }
static float vlc_to_vdp_hue(float hue) { float dummy; hue /= 360.f; hue = modff(hue, &dummy); if (hue > .5f) hue -= 1.f; return hue * (float)(2. * M_PI); }
float ceilf(float x) { modff(x, &x); if (x > 0.0) { x += 1.0; } return x; }
float floorf(float x) { modff(x, &x); if (x < 0.0) { x -= 1.0; } return x; }
float fmodf(float x, float div) { float n0; x /= div; x = modff(x, &n0); x *= div; return x; }
void plStepParticleSystem(PLparticles *ps, float dt) { assert(ps != NULL); if (ps->enabled == false) return; size_t activeParticles = 0; for (size_t i = 0 ; i < ps->particleCount ; ++i) { if (ps->particles[i].active) { ps->particles[i].p += vf3_s_mul(ps->particles[i].v, dt) + vf3_s_mul(ps->obj->v, dt); ps->particles[i].age += dt; activeParticles++; if (ps->particles[i].age > ps->particles[i].lifeTime) { ps->particles[i].active = false; int_array_push(&ps->freeParticles, i); activeParticles --; } } } // Auto disable if (ps->autoDisable) { if (activeParticles == 0) { ps->enabled = false; } return; } // Not off or disabled, emitt new particles float newPartCount = ps->emissionRate * dt * (1.0 + rand_percent(10)); float intPart; float frac = modff(newPartCount, &intPart); unsigned newParticles = (unsigned) intPart; // The fraction is handled with randomisation int rval = random() % 128; if ((float)rval/128.0f < frac) newParticles ++; for (unsigned i = 0 ; i < newParticles ; ++i) { if (ps->freeParticles.length > 0) { int i = int_array_remove(&ps->freeParticles, 0); ps->particles[i].active = true; ps->particles[i].age = 0.0; // Adjust lifetime by +-20 % ps->particles[i].lifeTime = ps->lifeTime + ps->lifeTime * rand_percent(20); ps->particles[i].p = v_q_rot(ps->p, ps->obj->q); ps->particles[i].v = v_q_rot(ps->v * vf3_set(rand_percent(10), rand_percent(10), rand_percent(10)), ps->obj->q); ps->particles[i].rgb = ps->rgb; } else { break; } } }
GstClockTime toGstClockTime(float time) { // Extract the integer part of the time (seconds) and the fractional part (microseconds). Attempt to // round the microseconds so no floating point precision is lost and we can perform an accurate seek. float seconds; float microSeconds = modff(time, &seconds) * 1000000; GTimeVal timeValue; timeValue.tv_sec = static_cast<glong>(seconds); timeValue.tv_usec = static_cast<glong>(roundf(microSeconds / 10000) * 10000); return GST_TIMEVAL_TO_TIME(timeValue); }
/** * validate * * test validation function for values returning NaN */ void __cdecl validate_isnan(float value) { float result_intpart; float result = modff(value, &result_intpart); if (!_isnan(result) || !_isnan(result_intpart)) { Fail("modff(%g) returned %10.9g with an intpart of %10.9g when it should have returned %10.9g with an intpart of %10.9g", value, result, result_intpart, PAL_NAN, PAL_NAN); } }
void render_level_map(LEVEL *levl, float xorg, float yorg) { /*int x,y; destroy_bitmap(levl_buf); levl_buf = create_bitmap(levl->sizex * 64, levl->sizey * 64); for (x = 0;x < levl->sizex;x++) for (y = 0;y < levl->sizey;y++) blit(tileset,levl_buf,levl->map[x + (y * levl->sizex)] * 64,0,x*64,y*64,64,64);*/ //x14 y10 float xint, yint; float xoff = modff(xorg, &xint); float yoff = modff(yorg, &yint); for (int y=yint; y<yint+11; y++) { if (y < levl->sizey && y >= 0) for (int x=xint; x<xint+14; x++) { if (x < levl->sizex && x >= 0) { masked_blit(tileset, buffer, levl->map[x+(y*levl->sizex)]*64,0, (x-xorg)*64, (y-yorg)*64, 64, 64); } } } }
float ceilf(float x) { float x1 = x; modff(x, &x); if (x1 > 0.0F && fabsf(x1 - x) > 0.0F) { x += 1.0F; } return x; }