void UpdateInfoBoxNextLegEqThermal(InfoBoxData &data) { const fixed next_leg_eq_thermal = CommonInterface::Calculated().next_leg_eq_thermal; if (negative(next_leg_eq_thermal)) { data.SetInvalid(); return; } SetVSpeed(data, next_leg_eq_thermal); }
/** * Check if all solutions of quadratic are real * * @return True if quadratic has at least one real solution */ gcc_pure bool check() const { if (negative(denom)) return false; if (da == fixed_zero) return false; return true; }
void build_structure() { int i, j, var, *lits1, length, clause, *vars_signs, lit; for (i=0; i<NB_VAR; i++) { neg_nb[i] = 0; pos_nb[i] = 0; } for (i=0; i<NB_CLAUSE; i++) { for(j=0; j<clause_length[i]; j++) { if (sat[i][j]>=NB_VAR) { var=sat[i][j]-NB_VAR; neg_nb[var]++; } else { var=sat[i][j]; pos_nb[var]++; } } if (sat[i][clause_length[i]] !=NONE) printf("erreur "), exit(0); } for(clause=0;clause<NB_CLAUSE;clause++) { length = clause_length[clause]; var_sign[clause] = (int *)malloc((2*length+1)*sizeof(int)); lits1 = sat[clause]; vars_signs = var_sign[clause]; for(lit=*lits1; lit!=NONE; lit=*(++lits1),(vars_signs+=2)) { if (negative(lit)) { *(vars_signs+1)= NEGATIVE; *vars_signs = get_var_from_lit(lit); } else { *(vars_signs+1)=POSITIVE; *vars_signs = lit; } } *vars_signs = NONE; } for (i=0; i<NB_VAR; i++) { neg_in[i] = (int *)malloc((neg_nb[i]+pos_nb[i]+1) * sizeof(int)); pos_in[i] = (int *)malloc((pos_nb[i]+neg_nb[i]+1) * sizeof(int)); if ( pos_in[i] == NULL ) exit( 20 ); neg_in[i][neg_nb[i]]=NONE; pos_in[i][pos_nb[i]]=NONE; neg_nb[i] = 0; pos_nb[i] = 0; var_state[i] = ACTIVE; } for (i=0; i<NB_CLAUSE; i++) { // if (i==774) // printf("kjhsdf"); lits1 = sat[i]; for(lit=*lits1; lit!=NONE; lit=*(++lits1)) { if (positive(lit)) pos_in[lit][pos_nb[lit]++] = i; else neg_in[get_var_from_lit(lit)] [neg_nb[get_var_from_lit(lit)]++] = i; } } }
void ElementStat::SetTimes(const fixed until_start_s, const fixed ts, const fixed time) { time_started = ts; if (negative(time_started) || negative(time)) /* not yet started */ time_elapsed = fixed(0); else time_elapsed = fdim(time, ts); if (solution_remaining.IsOk()) { time_remaining_now = solution_remaining.time_elapsed; time_remaining_start = fdim(time_remaining_now, until_start_s); time_planned = time_elapsed + time_remaining_start; } else { time_remaining_now = time_remaining_start = time_planned = fixed(0); } }
int main() { int arr[4]; int arr2[3][2]; float arr3[5]; int div, sum; int loopvar=0; float result; myint n; result = 4; while( n < result ) { arr[n] = n; n = n + 1; } for (loopvar = 1; loopvar <= n ; loopvar = loopvar + 1) { sum = sum + loopvar; } write("enter a divider"); div = read(); if (div != 0 && sum) { result = sum / div; if ((result >= 10) && !div) { arr[0] = negative(sum); } else { arr[1] = negative_float(sum, 1.5); } } else { return 0; } arr[2] = arr[0] * arr[1] + result + sum; result = myfunc3(arr2, arr3[2]); /* allow overloaded(type int or float) "write" function calls */ write(sum); write(result); return 0; }
void Check(const AbstractAirspace &airspace) { if (!CheckAirspace(airspace)) return; /* check delta below */ fixed base = airspace.GetBase().GetAltitude(altitude); fixed base_delta = base - altitude.altitude; if (!negative(base_delta) && base_delta < fabs(nearest_delta)) { nearest = &airspace; nearest_delta = base_delta; } /* check delta above */ fixed top = airspace.GetTop().GetAltitude(altitude); fixed top_delta = altitude.altitude - top; if (!negative(top_delta) && top_delta < fabs(nearest_delta)) { nearest = &airspace; nearest_delta = -top_delta; } }
void UpdateInfoBoxThermalRatio(InfoBoxData &data) { // Set Value if (negative(CommonInterface::Calculated().circling_percentage)) data.SetInvalid(); else data.SetValue(_T("%2.0f%%"), CommonInterface::Calculated().circling_percentage); }
void matchBoolean() { givenACodeSampleToTokenize yes("YES"); ASSERT_EQUALS(false, Token::Match(yes.tokens(), "%bool%")); givenACodeSampleToTokenize positive("true"); ASSERT_EQUALS(true, Token::Match(positive.tokens(), "%bool%")); givenACodeSampleToTokenize negative("false"); ASSERT_EQUALS(true, Token::Match(negative.tokens(), "%bool%")); }
fixed DistanceMemento::Distance(const GeoPoint& _origin, const GeoPoint& _destination) const { if (negative(value) || _origin != origin || _destination != destination) { origin = _origin; destination = _destination; value = origin.Distance(destination); } return value; }
BrokenDateTime NMEAInfo::GetDateTimeAt(double other_time) const { if (negative(other_time)) return BrokenDateTime::Invalid(); if (!time_available || !date_time_utc.IsDatePlausible()) return BrokenDateTime(BrokenDate::Invalid(), BrokenTime::FromSecondOfDayChecked(int(other_time))); return date_time_utc + int(other_time - time); }
static void choose_t(ge25519_aff *t, unsigned long long pos, signed char b) { /* constant time */ fe25519 v; *t = ge25519_base_multiples_affine[5*pos+0]; cmov_aff(t, &ge25519_base_multiples_affine[5*pos+1],equal(b,1) | equal(b,-1)); cmov_aff(t, &ge25519_base_multiples_affine[5*pos+2],equal(b,2) | equal(b,-2)); cmov_aff(t, &ge25519_base_multiples_affine[5*pos+3],equal(b,3) | equal(b,-3)); cmov_aff(t, &ge25519_base_multiples_affine[5*pos+4],equal(b,-4)); fe25519_neg(&v, &t->x); fe25519_cmov(&t->x, &v, negative(b)); }
void FormatTime(TCHAR* buffer, fixed _time) { if (negative(_time)) { *buffer++ = _T('-'); _time = -_time; } const BrokenTime time = BrokenTime::FromSecondOfDayChecked((unsigned)_time); _stprintf(buffer, _T("%02u:%02u:%02u"), time.hour, time.minute, time.second); }
void Volkslogger::Waypoint::SetLocation(GeoPoint gp) { uint32_t llat = labs((long)(gp.latitude.Degrees() * 60000)); uint32_t llon = labs((long)(gp.longitude.Degrees() * 60000)); if (negative(gp.longitude.Native())) type_and_longitude_sign |= 0x80; else type_and_longitude_sign &= ~0x80; latitude[0] = llat >> 16; if (negative(gp.latitude.Native())) latitude[0] |= 0x80; latitude[1] = llat >> 8; latitude[2] = llat; longitude[0] = llon >> 16; longitude[1] = llon >> 8; longitude[2] = llon; }
static void choose_t(ge25519_aff *t, signed char b) { fe25519 v; unsigned char u; signed char const mask = b >> 7; u = (b + mask) ^ mask; *t = ge25519_base_multiples_affine[u]; fe25519_neg(&v, &t->x); fe25519_cmov(&t->x, &v, negative(b)); }
Angle SunEphemeris::GetHourAngle(Angle lat, Angle declin) { Angle dfo = Angle::Degrees(SUN_DIAMETER / 2 + AIR_REFRACTION); // Correction: different sign at southern hemisphere if (negative(lat.Degrees())) dfo.Flip(); fixed fo = (declin + dfo).tan() * lat.tan(); return Angle::asin(fo) + Angle::QuarterCircle(); }
Angle SunEphemeris::GetHourAngleTwilight(Angle lat, Angle declin) { Angle df1 = Angle::Degrees(6); // Correction: different sign at southern hemisphere if (negative(lat.Degrees())) df1.Flip(); fixed fi = (declin + df1).tan() * lat.tan(); return Angle::asin(fi) + Angle::QuarterCircle(); }
static void BallastDumpProcessTimer() { ComputerSettings &settings_computer = CommonInterface::SetComputerSettings(); if (!settings_computer.ballast_timer_active) return; // only update every 5 seconds to stop flooding the devices static GPSClock ballast_clock(fixed(5)); const NMEAInfo &basic = CommonInterface::Basic(); // We don't know how fast the water is flowing so don't pretend that we do if (settings_computer.plane.dump_time <= 0) { settings_computer.ballast_timer_active = false; return; } fixed dt = ballast_clock.delta_advance(basic.time); if (negative(dt)) return; GlidePolar &glide_polar = settings_computer.glide_polar_task; fixed ballast = glide_polar.GetBallast(); fixed percent_per_second = fixed_one / settings_computer.plane.dump_time; ballast -= dt * percent_per_second; if (negative(ballast)) { settings_computer.ballast_timer_active = false; ballast = fixed_zero; } glide_polar.SetBallast(ballast); if (protected_task_manager != NULL) protected_task_manager->SetGlidePolar(glide_polar); }
void matchNumeric() const { givenACodeSampleToTokenize nonNumeric("abc", true); ASSERT_EQUALS(false, Token::Match(nonNumeric.tokens(), "%num%")); givenACodeSampleToTokenize binary("101010b", true); ASSERT_EQUALS(true, Token::Match(binary.tokens(), "%num%")); givenACodeSampleToTokenize octal("0123", true); ASSERT_EQUALS(true, Token::Match(octal.tokens(), "%num%")); givenACodeSampleToTokenize decimal("4567", true); ASSERT_EQUALS(true, Token::Match(decimal.tokens(), "%num%")); givenACodeSampleToTokenize hexadecimal("0xDEADBEEF", true); ASSERT_EQUALS(true, Token::Match(hexadecimal.tokens(), "%num%")); givenACodeSampleToTokenize floatingPoint("0.0f", true); ASSERT_EQUALS(true, Token::Match(floatingPoint.tokens(), "%num%")); givenACodeSampleToTokenize doublePrecision("0.0d", true); ASSERT_EQUALS(true, Token::Match(doublePrecision.tokens(), "%num%")); givenACodeSampleToTokenize signedLong("0L", true); ASSERT_EQUALS(true, Token::Match(signedLong.tokens(), "%num%")); givenACodeSampleToTokenize negativeSignedLong("-0L", true); ASSERT_EQUALS(true, Token::Match(negativeSignedLong.tokens(), "- %num%")); givenACodeSampleToTokenize positiveSignedLong("+0L", true); ASSERT_EQUALS(true, Token::Match(positiveSignedLong.tokens(), "+ %num%")); givenACodeSampleToTokenize unsignedInt("0U", true); ASSERT_EQUALS(true, Token::Match(unsignedInt.tokens(), "%num%")); givenACodeSampleToTokenize unsignedLong("0UL", true); ASSERT_EQUALS(true, Token::Match(unsignedLong.tokens(), "%num%")); givenACodeSampleToTokenize unsignedLongLong("0ULL", true); ASSERT_EQUALS(true, Token::Match(unsignedLongLong.tokens(), "%num%")); givenACodeSampleToTokenize positive("+666", true); ASSERT_EQUALS(true, Token::Match(positive.tokens(), "+ %num%")); givenACodeSampleToTokenize negative("-42", true); ASSERT_EQUALS(true, Token::Match(negative.tokens(), "- %num%")); givenACodeSampleToTokenize negativeNull("-.0", true); ASSERT_EQUALS(true, Token::Match(negativeNull.tokens(), "- %num%")); givenACodeSampleToTokenize positiveNull("+.0", true); ASSERT_EQUALS(true, Token::Match(positiveNull.tokens(), "+ %num%")); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open())); connect(ui->actionReset, SIGNAL(triggered()), this, SLOT(reset())); connect(ui->btn_Left, SIGNAL(clicked()), this, SLOT(turnLeft())); connect(ui->btn_Right, SIGNAL(clicked()), this, SLOT(turnRight())); connect(ui->actionRgb2gray, SIGNAL(triggered()), this, SLOT(rgb2gray())); connect(ui->actionRgb2bw, SIGNAL(triggered()), this, SLOT(rgb2bw())); connect(ui->actionNegative, SIGNAL(triggered()), this, SLOT(negative())); connect(ui->actionStretch, SIGNAL(triggered()), this, SLOT(stretch())); connect(ui->actionLog, SIGNAL(triggered()), this, SLOT(log())); connect(ui->actionHistogramEqualize, SIGNAL(triggered()), this, SLOT(histogramEqualize())); connect(ui->actionHistogramExactSpecifiedEqualize, SIGNAL(triggered()), this, SLOT(histogramExactSpecifiedEqualize())); connect(ui->actionSpatialFilter, SIGNAL(triggered()), this, SLOT(spatialFilter())); connect(ui->actionMedianFilter, SIGNAL(triggered()), this, SLOT(medianFilter())); connect(ui->actionFFT, SIGNAL(triggered()), this, SLOT(makeFFT())); connect(ui->actionOilPaint, SIGNAL(triggered()), this, SLOT(oilPaint())); connect(ui->actionRelief, SIGNAL(triggered()), this, SLOT(relief())); connect(ui->actionEdgeExtraction, SIGNAL(triggered()), this, SLOT(edgeExtraction())); connect(ui->actionGaussianBlur, SIGNAL(triggered()), this, SLOT(gaussianBlur())); connect(ui->actionOpenOperate, SIGNAL(triggered()), this, SLOT(openOp())); connect(ui->actionCloseOperate, SIGNAL(triggered()), this, SLOT(closeOp())); connect(ui->actionExpansion, SIGNAL(triggered()), this, SLOT(expansionOp())); connect(ui->actionCorrosion, SIGNAL(triggered()), this, SLOT(corrosionOp())); connect(ui->checkBox, SIGNAL(toggled(bool)), this, SLOT(saveCheck(bool))); connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save())); this->ui->graphicsView->setScene(Q_NULLPTR); this->pixmapItem = Q_NULLPTR; this->directory = new QDir(); this->imageProcessor = Q_NULLPTR; this->ui->actionReset->setEnabled(false); this->ui->btn_Left->setEnabled(false); this->ui->btn_Right->setEnabled(false); this->ui->actionRgb2gray->setEnabled(false); this->ui->actionRgb2bw->setEnabled(false); this->ui->actionNegative->setEnabled(false); this->ui->actionStretch->setEnabled(false); this->ui->actionLog->setEnabled(false); this->ui->actionHistogramEqualize->setEnabled(false); this->ui->actionHistogramExactSpecifiedEqualize->setEnabled(false); this->ui->actionSpatialFilter->setEnabled(false); this->ui->actionMedianFilter->setEnabled(false); this->ui->actionFFT->setEnabled(false); this->ui->actionOilPaint->setEnabled(false); this->ui->actionRelief->setEnabled(false); this->ui->actionEdgeExtraction->setEnabled(false); this->ui->actionGaussianBlur->setEnabled(false); this->ui->actionSave->setEnabled(false); }
gcc_pure static GeoPoint IntermediatePoint(const GeoPoint &loc1, const GeoPoint &loc2, Angle dthis, Angle dtotal) { assert(loc1.IsValid()); assert(loc2.IsValid()); if (loc1.longitude == loc2.longitude && loc1.latitude == loc2.latitude) return loc1; if (!positive(dtotal.Native())) return loc1; assert(dthis <= dtotal && !negative(dthis.Native())); const fixed A = (dtotal - dthis).sin(); const fixed B = dthis.sin(); const auto sc1 = loc1.latitude.SinCos(); const fixed sin_loc1_lat = sc1.first, cos_loc1_lat = sc1.second; const auto sc2 = loc2.latitude.SinCos(); const fixed sin_loc2_lat = sc2.first, cos_loc2_lat = sc2.second; const auto sc3 = loc1.longitude.SinCos(); const fixed sin_loc1_lon = sc3.first, cos_loc1_lon = sc3.second; const auto sc4 = loc2.longitude.SinCos(); const fixed sin_loc2_lon = sc4.first, cos_loc2_lon = sc4.second; const fixed a_cos_loc1_lat = SmallMult(A, cos_loc1_lat); const fixed b_cos_loc2_lat = SmallMult(B, cos_loc2_lat); const fixed x = SmallMult(a_cos_loc1_lat, cos_loc1_lon) + SmallMult(b_cos_loc2_lat, cos_loc2_lon); const fixed y = SmallMult(a_cos_loc1_lat, sin_loc1_lon) + SmallMult(b_cos_loc2_lat, sin_loc2_lon); const fixed z = SmallMult(A, sin_loc1_lat) + SmallMult(B, sin_loc2_lat); GeoPoint loc3; loc3.latitude = Angle::FromXY(TinyHypot(x, y), z); loc3.longitude = Angle::FromXY(x, y); loc3.Normalize(); // ensure longitude is within -180:180 #ifdef INSTRUMENT_TASK count_distbearing++; #endif return loc3; }
void GlidePolar::solve_ld() { /* // this method to be used if polar is not parabolic GlidePolarVopt gpvopt(*this, Vmin, Vmax); VbestLD = gpvopt.find_min(VbestLD); */ assert(!negative(mc)); VbestLD = max(Vmin, min(Vmax, sqrt((polar_c+mc)/polar_a))); SbestLD = SinkRate(VbestLD); bestLD = VbestLD / SbestLD; }
fixed GlidePolar::GetBestGlideRatioSpeed(fixed head_wind) const { assert(polar.IsValid()); fixed s = sqr(head_wind) + (mc + polar.c + polar.b * head_wind) / polar.a; if (negative(s)) /* should never happen, but just in case */ return GetVMax(); return head_wind + sqrt(s); }
void FlyingComputer::Compute(fixed takeoff_speed, const AircraftState &state, fixed dt, FlyingState &flying) { if (negative(state.time)) return; if (state.ground_speed > takeoff_speed) Moving(flying, state.time, dt, state.location); else Stationary(flying, state.time, dt, state.location); }
void UpdateInfoBoxTaskSpeedHour(InfoBoxData &data) { const WindowStats &window = CommonInterface::Calculated().task_stats.last_hour; if (negative(window.duration)) { data.SetInvalid(); return; } data.SetValue(_T("%2.0f"), Units::ToUserTaskSpeed(window.speed)); data.SetValueUnit(Units::current.task_speed_unit); }
/** * Parses non-negative floating-point angle value in degrees. */ static bool ReadBearing(NMEAInputLine &line, Angle &value_r) { fixed value; if (!line.ReadChecked(value)) return false; if (negative(value) || value > fixed(360)) return false; value_r = Angle::Degrees(value).AsBearing(); return true; }
bool ConditionMonitor::Ready_Time_Notification(fixed T) { if (!positive(T)) return false; if (negative(LastTime_Notification) || T < LastTime_Notification) return true; if (T >= LastTime_Notification + Interval_Notification) return true; return false; }
/** * Calculating the hourangle for twilight times * @param lat Latitude * @param declin Declination * @return The hourangle for twilight times */ Angle SunEphemeris::GetHourAngleTwilight(Angle lat, Angle declin) { Angle df1 = Angle::degrees(fixed(6)); // Correction: different sign at southern hemisphere if (negative(lat.value_degrees())) df1.flip(); fixed fi = (declin + df1).tan() * lat.tan(); fi = asin(fi) + fixed_half_pi; return Angle::radians(fi); }
void Replay::OnTimer() { if (!Update()) return; unsigned schedule; if (!positive(time_scale)) schedule = 1000; else if (!negative(fast_forward)) schedule = 100; else if (negative(virtual_time) || !next_data.time_available) schedule = 500; else if (cli != nullptr) schedule = 1000; else { fixed delta_s = (next_data.time - virtual_time) / time_scale; int delta_ms = int(delta_s * 1000); schedule = Clamp(delta_ms, 100, 3000); } Timer::Schedule(schedule); }
int calc(int a, int b, int type) { // write code here if(type == 1) { // Product if(b == 1) return a; return a + calc(a, calc(b, 1, -1), 1); // a + a * (b - 1) } else if(type == 0) { // Divide if(a < b) return 0; return 1 + calc(calc(a, b, -1), b, 0); // 1 + (a - b) / b; } else { // Minus return a + negative(b); } }
static void FormatLongitude(char *buffer, size_t buffer_size, Angle longitude) { // Calculate Longitude sign char sign = negative(longitude.Native()) ? 'W' : 'E'; double mlong(longitude.AbsoluteDegrees()); int dd = (int)mlong; // Calculate minutes double mins = (mlong - dd) * 60.0; // Save the string to the buffer snprintf(buffer, buffer_size, "%02d%06.3f,%c", dd, mins, sign); }