diff options
author | Jeremie Guichard <djebrest@gmail.com> | 2017-03-08 13:41:41 +0700 |
---|---|---|
committer | Jeremie Guichard <djebrest@gmail.com> | 2017-03-08 14:04:17 +0700 |
commit | 406e4287eb96e10ddfd22163f0e863e353470c68 (patch) | |
tree | 1a859821cdd37485b7d9ce4c0404f73fdf68e78b | |
parent | 9c2619ea3bcf8a0ad40a758692c26a5aec350c7f (diff) | |
download | subsurface-406e4287eb96e10ddfd22163f0e863e353470c68.tar.gz |
Change calls to rint into lrint avoiding conversion warnings
Using gcc option "-Wfloat-conversion" is useful to catch
potential conversion errors (where lrint should be used).
rint returns double and still raises the same warning,
this is why this change updates all rint calls to lrint.
In few places, where input type is a float, corresponding
lrinf is used.
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
-rw-r--r-- | core/dive.c | 12 | ||||
-rw-r--r-- | core/dive.h | 10 | ||||
-rw-r--r-- | core/divelist.c | 2 | ||||
-rw-r--r-- | core/gaspressures.c | 6 | ||||
-rw-r--r-- | core/gpslocation.cpp | 4 | ||||
-rw-r--r-- | core/libdivecomputer.c | 30 | ||||
-rw-r--r-- | core/load-git.c | 16 | ||||
-rw-r--r-- | core/parse-xml.c | 20 | ||||
-rw-r--r-- | core/planner.c | 4 | ||||
-rw-r--r-- | core/profile.c | 2 | ||||
-rw-r--r-- | core/qthelper.cpp | 30 | ||||
-rw-r--r-- | core/statistics.c | 4 | ||||
-rw-r--r-- | core/uemis-downloader.c | 2 | ||||
-rw-r--r-- | core/uemis.c | 2 | ||||
-rw-r--r-- | core/units.h | 14 | ||||
-rw-r--r-- | desktop-widgets/diveplanner.cpp | 12 | ||||
-rw-r--r-- | desktop-widgets/globe.cpp | 10 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_graph.cpp | 8 | ||||
-rw-r--r-- | mobile-widgets/qmlprofile.cpp | 2 | ||||
-rw-r--r-- | profile-widget/profilewidget2.cpp | 10 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 2 |
21 files changed, 101 insertions, 101 deletions
diff --git a/core/dive.c b/core/dive.c index 48dd929f4..6c438b1a3 100644 --- a/core/dive.c +++ b/core/dive.c @@ -243,15 +243,15 @@ double get_volume_units(unsigned int ml, int *frac, const char **units) int units_to_sac(double volume) { if (get_units()->volume == CUFT) - return rint(cuft_to_l(volume) * 1000.0); + return lrint(cuft_to_l(volume) * 1000.0); else - return rint(volume * 1000); + return lrint(volume * 1000); } unsigned int units_to_depth(double depth) { if (get_units()->length == METERS) - return rint(depth * 1000); + return lrint(depth * 1000); return feet_to_mm(depth); } @@ -872,7 +872,7 @@ int gas_volume(cylinder_t *cyl, pressure_t p) { double bar = p.mbar / 1000.0; double z_factor = gas_compressibility_factor(&cyl->gasmix, bar); - return rint(cyl->type.size.mliter * bar_to_atm(bar) / z_factor); + return lrint(cyl->type.size.mliter * bar_to_atm(bar) / z_factor); } /* @@ -1019,7 +1019,7 @@ static void match_standard_cylinder(cylinder_type_t *type) default: return; } - len = snprintf(buffer, sizeof(buffer), fmt, (int)rint(cuft)); + len = snprintf(buffer, sizeof(buffer), fmt, (int)lrint(cuft)); p = malloc(len + 1); if (!p) return; @@ -1056,7 +1056,7 @@ static void sanitize_cylinder_type(cylinder_type_t *type) volume_of_air = cuft_to_l(type->size.mliter); /* milliliters at 1 atm: not corrected for compressibility! */ volume = volume_of_air / bar_to_atm(bar); - type->size.mliter = rint(volume); + type->size.mliter = lrint(volume); } /* Ok, we have both size and pressure: try to match a description */ diff --git a/core/dive.h b/core/dive.h index ba92e1083..164886df6 100644 --- a/core/dive.h +++ b/core/dive.h @@ -173,7 +173,7 @@ static inline int interpolate(int a, int b, int part, int whole) /* It is doubtful that we actually need floating point for this, but whatever */ if (whole) { double x = (double)a * (whole - part) + (double)b * part; - return rint(x / whole); + return lrint(x / whole); } return (a+b)/2; } @@ -440,7 +440,7 @@ static inline int calculate_depth_to_mbar(int depth, pressure_t surface_pressure if (salinity < 500) salinity += FRESHWATER_SALINITY; specific_weight = salinity / 10000.0 * 0.981; - mbar += rint(depth / 10.0 * specific_weight); + mbar += lrint(depth / 10.0 * specific_weight); return mbar; } @@ -470,7 +470,7 @@ static inline int rel_mbar_to_depth(int mbar, struct dive *dive) if (dive->dc.salinity) specific_weight = dive->dc.salinity / 10000.0 * 0.981; /* whole mbar gives us cm precision */ - cm = rint(mbar / specific_weight); + cm = lrint(mbar / specific_weight); return cm * 10; } @@ -489,7 +489,7 @@ static inline depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit, struct d depth_t rounded_depth; double depth = (double) mbar_to_depth(po2_limit.mbar * 1000 / get_o2(mix), dive); - rounded_depth.mm = rint(depth / roundto) * roundto; + rounded_depth.mm = lrint(depth / roundto) * roundto; return rounded_depth; } @@ -500,7 +500,7 @@ static inline depth_t gas_mnd(struct gasmix *mix, depth_t end, struct dive *dive ppo2n2.mbar = depth_to_mbar(end.mm, dive); double maxambient = ppo2n2.mbar / (1 - get_he(mix) / 1000.0); - rounded_depth.mm = rint(mbar_to_depth(maxambient, dive) / roundto) * roundto; + rounded_depth.mm = lrint(((double)mbar_to_depth(maxambient, dive)) / roundto) * roundto; return rounded_depth; } diff --git a/core/divelist.c b/core/divelist.c index 44401b7c0..d47b034bd 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -183,7 +183,7 @@ static int calculate_otu(struct dive *dive) if (po2 >= 500) otu += pow((po2 - 500) / 1000.0, 0.83) * t / 30.0; } - return rint(otu); + return lrint(otu); } /* calculate CNS for a dive - this only takes the first divecomputer into account */ int const cns_table[][3] = { diff --git a/core/gaspressures.c b/core/gaspressures.c index 5d3fc9791..e74f26d3b 100644 --- a/core/gaspressures.c +++ b/core/gaspressures.c @@ -148,7 +148,7 @@ static void fill_missing_segment_pressures(pr_track_t *list, enum interpolation_ case TIME: if (list->t_end && (tmp->t_start - tmp->t_end)) { magic = (list->t_start - tmp->t_end) / (tmp->t_start - tmp->t_end); - list->end = rint(start - (start - end) * magic); + list->end = lrint(start - (start - end) * magic); } else { list->end = start; } @@ -290,11 +290,11 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, magic = (interpolate.end - interpolate.start) / (double)interpolate.pressure_time; /* Use that overall pressure change to update the current pressure */ - cur_pr[cyl] = rint(interpolate.start + magic * interpolate.acc_pressure_time); + cur_pr[cyl] = lrint(interpolate.start + magic * interpolate.acc_pressure_time); } } else { magic = (interpolate.end - interpolate.start) / (segment->t_end - segment->t_start); - cur_pr[cyl] = rint(segment->start + magic * (entry->sec - segment->t_start)); + cur_pr[cyl] = lrint(segment->start + magic * (entry->sec - segment->t_start)); } *save_interpolated = cur_pr[cyl]; // and store the interpolated data in plot_info } diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp index d3f91ebaf..782d37226 100644 --- a/core/gpslocation.cpp +++ b/core/gpslocation.cpp @@ -157,8 +157,8 @@ void GpsLocation::newPosition(QGeoPositionInfo pos) gpsTracker gt; gt.when = pos.timestamp().toTime_t(); gt.when += gettimezoneoffset(gt.when); - gt.latitude.udeg = rint(pos.coordinate().latitude() * 1000000); - gt.longitude.udeg = rint(pos.coordinate().longitude() * 1000000); + gt.latitude.udeg = lrint(pos.coordinate().latitude() * 1000000); + gt.longitude.udeg = lrint(pos.coordinate().longitude() * 1000000); addFixToStorage(gt); } } diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index b7eb4c32e..2d8c79b4c 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -117,8 +117,8 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t if (i >= MAX_CYLINDERS) continue; - o2 = rint(gasmix.oxygen * 1000); - he = rint(gasmix.helium * 1000); + o2 = lrint(gasmix.oxygen * 1000); + he = lrint(gasmix.helium * 1000); /* Ignore bogus data - libdivecomputer does some crazy stuff */ if (o2 + he <= O2_IN_AIR || o2 > 1000) { @@ -149,8 +149,8 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t if (rc == DC_STATUS_SUCCESS) { cylinder_t *cyl = dive->cylinder + i; - cyl->type.size.mliter = rint(tank.volume * 1000); - cyl->type.workingpressure.mbar = rint(tank.workpressure * 1000); + cyl->type.size.mliter = lrint(tank.volume * 1000); + cyl->type.workingpressure.mbar = lrint(tank.workpressure * 1000); cyl->cylinder_use = OC_GAS; if (tank.type & DC_TANKINFO_CC_O2) @@ -330,7 +330,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) finish_sample(dc); break; case DC_SAMPLE_DEPTH: - sample->depth.mm = rint(value.depth * 1000); + sample->depth.mm = lrint(value.depth * 1000); break; case DC_SAMPLE_PRESSURE: /* Do we already have a pressure reading? */ @@ -341,7 +341,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) break; } sample->sensor = value.pressure.tank; - sample->cylinderpressure.mbar = rint(value.pressure.value * 1000); + sample->cylinderpressure.mbar = lrint(value.pressure.value * 1000); break; case DC_SAMPLE_GASMIX: handle_gasmix(dc, sample, value.gasmix); @@ -373,11 +373,11 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) #if DC_VERSION_CHECK(0, 3, 0) case DC_SAMPLE_SETPOINT: /* for us a setpoint means constant pO2 from here */ - sample->setpoint.mbar = po2 = rint(value.setpoint * 1000); + sample->setpoint.mbar = po2 = lrint(value.setpoint * 1000); break; case DC_SAMPLE_PPO2: if (nsensor < 3) - sample->o2sensor[nsensor].mbar = rint(value.ppo2 * 1000); + sample->o2sensor[nsensor].mbar = lrint(value.ppo2 * 1000); else report_error("%d is more o2 sensors than we can handle", nsensor); nsensor++; @@ -386,22 +386,22 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) dc->no_o2sensors = nsensor; break; case DC_SAMPLE_CNS: - sample->cns = cns = rint(value.cns * 100); + sample->cns = cns = lrint(value.cns * 100); break; case DC_SAMPLE_DECO: if (value.deco.type == DC_DECO_NDL) { sample->ndl.seconds = ndl = value.deco.time; - sample->stopdepth.mm = stopdepth = rint(value.deco.depth * 1000.0); + sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0); sample->in_deco = in_deco = false; } else if (value.deco.type == DC_DECO_DECOSTOP || value.deco.type == DC_DECO_DEEPSTOP) { sample->in_deco = in_deco = true; - sample->stopdepth.mm = stopdepth = rint(value.deco.depth * 1000.0); + sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0); sample->stoptime.seconds = stoptime = value.deco.time; ndl = 0; } else if (value.deco.type == DC_DECO_SAFETYSTOP) { sample->in_deco = in_deco = false; - sample->stopdepth.mm = stopdepth = rint(value.deco.depth * 1000.0); + sample->stopdepth.mm = stopdepth = lrint(value.deco.depth * 1000.0); sample->stoptime.seconds = stoptime = value.deco.time; } #endif @@ -627,7 +627,7 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, struct device_data_t return rc; } if (rc == DC_STATUS_SUCCESS) - dive->dc.maxdepth.mm = rint(maxdepth * 1000); + dive->dc.maxdepth.mm = lrint(maxdepth * 1000); #if DC_VERSION_CHECK(0, 5, 0) && defined(DC_GASMIX_UNKNOWN) // if this is defined then we have a fairly late version of libdivecomputer @@ -678,7 +678,7 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, struct device_data_t return rc; } if (rc == DC_STATUS_SUCCESS) - dive->dc.salinity = rint(salinity.density * 10.0); + dive->dc.salinity = lrint(salinity.density * 10.0); double surface_pressure = 0; rc = dc_parser_get_field(parser, DC_FIELD_ATMOSPHERIC, 0, &surface_pressure); @@ -687,7 +687,7 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, struct device_data_t return rc; } if (rc == DC_STATUS_SUCCESS) - dive->dc.surface_pressure.mbar = rint(surface_pressure * 1000.0); + dive->dc.surface_pressure.mbar = lrint(surface_pressure * 1000.0); #endif #ifdef DC_FIELD_STRING diff --git a/core/load-git.c b/core/load-git.c index 05d2112b5..03e7f8694 100644 --- a/core/load-git.c +++ b/core/load-git.c @@ -81,40 +81,40 @@ static temperature_t get_temperature(const char *line) static depth_t get_depth(const char *line) { depth_t d; - d.mm = rint(1000*ascii_strtod(line, NULL)); + d.mm = lrint(1000*ascii_strtod(line, NULL)); return d; } static volume_t get_volume(const char *line) { volume_t v; - v.mliter = rint(1000*ascii_strtod(line, NULL)); + v.mliter = lrint(1000*ascii_strtod(line, NULL)); return v; } static weight_t get_weight(const char *line) { weight_t w; - w.grams = rint(1000*ascii_strtod(line, NULL)); + w.grams = lrint(1000*ascii_strtod(line, NULL)); return w; } static pressure_t get_pressure(const char *line) { pressure_t p; - p.mbar = rint(1000*ascii_strtod(line, NULL)); + p.mbar = lrint(1000*ascii_strtod(line, NULL)); return p; } static int get_salinity(const char *line) { - return rint(10*ascii_strtod(line, NULL)); + return lrint(10*ascii_strtod(line, NULL)); } static fraction_t get_fraction(const char *line) { fraction_t f; - f.permille = rint(10*ascii_strtod(line, NULL)); + f.permille = lrint(10*ascii_strtod(line, NULL)); return f; } @@ -568,10 +568,10 @@ static char *parse_sample_unit(struct sample *sample, double val, char *unit) /* The units are "°C", "m" or "bar", so let's just look at the first character */ switch (*unit) { case 'm': - sample->depth.mm = rint(1000*val); + sample->depth.mm = lrint(1000*val); break; case 'b': - sample->cylinderpressure.mbar = rint(1000*val); + sample->cylinderpressure.mbar = lrint(1000*val); break; default: sample->temperature.mkelvin = C_to_mkelvin(val); diff --git a/core/parse-xml.c b/core/parse-xml.c index 0032a5c32..23dc76715 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -286,7 +286,7 @@ static enum number_type parse_float(const char *buffer, double *res, const char if (errno || *endp == buffer) return NEITHER; if (**endp == ',') { - if (IS_FP_SAME(val, rint(val))) { + if (IS_FP_SAME(val, lrint(val))) { /* we really want to send an error if this is a Subsurface native file * as this is likely indication of a bug - but right now we don't have * that information available */ @@ -338,7 +338,7 @@ static void pressure(char *buffer, pressure_t *pressure) break; } if (fabs(mbar) > 5 && fabs(mbar) < 5000000) { - pressure->mbar = rint(mbar); + pressure->mbar = lrint(mbar); break; } /* fallthrough */ @@ -358,7 +358,7 @@ static void salinity(char *buffer, int *salinity) union int_or_float val; switch (integer_or_float(buffer, &val)) { case FLOAT: - *salinity = rint(val.fp * 10.0); + *salinity = lrint(val.fp * 10.0); break; default: printf("Strange salinity reading %s\n", buffer); @@ -373,7 +373,7 @@ static void depth(char *buffer, depth_t *depth) case FLOAT: switch (xml_parsing_units.length) { case METERS: - depth->mm = rint(val.fp * 1000); + depth->mm = lrint(val.fp * 1000); break; case FEET: depth->mm = feet_to_mm(val.fp); @@ -405,7 +405,7 @@ static void weight(char *buffer, weight_t *weight) case FLOAT: switch (xml_parsing_units.weight) { case KG: - weight->grams = rint(val.fp * 1000); + weight->grams = lrint(val.fp * 1000); break; case LBS: weight->grams = lbs_to_grams(val.fp); @@ -510,7 +510,7 @@ static void percent(char *buffer, fraction_t *fraction) /* Then turn percent into our integer permille format */ if (val >= 0 && val <= 100.0) { - fraction->permille = rint(val * 10); + fraction->permille = lrint(val * 10); break; } default: @@ -541,7 +541,7 @@ static void cylindersize(char *buffer, volume_t *volume) switch (integer_or_float(buffer, &val)) { case FLOAT: - volume->mliter = rint(val.fp * 1000); + volume->mliter = lrint(val.fp * 1000); break; default: @@ -614,7 +614,7 @@ static void get_rating(char *buffer, int *i) static void double_to_o2pressure(char *buffer, o2pressure_t *i) { - i->mbar = rint(ascii_strtod(buffer, NULL) * 1000.0); + i->mbar = lrint(ascii_strtod(buffer, NULL) * 1000.0); } static void hex_value(char *buffer, uint32_t *i) @@ -697,7 +697,7 @@ static void psi_or_bar(char *buffer, pressure_t *pressure) if (val.fp > 400) pressure->mbar = psi_to_mbar(val.fp); else - pressure->mbar = rint(val.fp * 1000); + pressure->mbar = lrint(val.fp * 1000); break; default: fprintf(stderr, "Crazy Diving Log PSI reading %s\n", buffer); @@ -3182,7 +3182,7 @@ extern int divinglog_profile(void *handle, int columns, char **data, char **colu if (atoi(ppo2_3) > 0) cur_sample->o2sensor[2].mbar = atoi(ppo2_3) * 100; if (atoi(cns) > 0) - cur_sample->cns = rint(atoi(cns) / 10); + cur_sample->cns = lrintf(atoi(cns) / 10.0f); if (atoi(setpoint) > 0) cur_sample->setpoint.mbar = atoi(setpoint) * 100; diff --git a/core/planner.c b/core/planner.c index ad7678188..cc099b01f 100644 --- a/core/planner.c +++ b/core/planner.c @@ -1406,8 +1406,8 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false); if (decoMode() == VPMB) { - diveplan->eff_gfhigh = rint(100.0 * regressionb()); - diveplan->eff_gflow = rint(100.0 * (regressiona() * first_stop_depth + regressionb())); + diveplan->eff_gfhigh = lrint(100.0 * regressionb()); + diveplan->eff_gflow = lrint(100.0 * (regressiona() * first_stop_depth + regressionb())); } create_dive_from_plan(diveplan, is_planner); diff --git a/core/profile.c b/core/profile.c index 502952bc7..484d9b15a 100644 --- a/core/profile.c +++ b/core/profile.c @@ -760,7 +760,7 @@ static int sac_between(struct dive *dive, struct plot_data *first, struct plot_d pressuretime /= 60; /* SAC = mliter per minute */ - return rint(airuse / pressuretime); + return lrint(airuse / pressuretime); } /* diff --git a/core/qthelper.cpp b/core/qthelper.cpp index e2615ec31..d6de2ebf9 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -51,9 +51,9 @@ QString weight_string(int weight_in_grams) } else { double lbs = grams_to_lbs(weight_in_grams); if (lbs >= 40.0) - lbs = rint(lbs + 0.5); + lbs = lrint(lbs + 0.5); else - lbs = rint(lbs + 0.05); + lbs = lrint(lbs + 0.05); str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1); } return (str); @@ -264,8 +264,8 @@ bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_te if (!(*parsed = parseGpsText(gps_text, &latitude, &longitude))) return false; - latudeg = rint(1000000 * latitude); - longudeg = rint(1000000 * longitude); + latudeg = lrint(1000000 * latitude); + longudeg = lrint(1000000 * longitude); /* if dive gps didn't change, nothing changed */ if (dive->latitude.udeg == latudeg && dive->longitude.udeg == longudeg) @@ -843,13 +843,13 @@ int parseWeightToGrams(const QString &text) return 0; double number = numOnly.toDouble(); if (text.contains(QObject::tr("kg"), Qt::CaseInsensitive)) { - grams = rint(number * 1000); + grams = lrint(number * 1000); } else if (text.contains(QObject::tr("lbs"), Qt::CaseInsensitive)) { grams = lbs_to_grams(number); } else { switch (prefs.units.weight) { case units::KG: - grams = rint(number * 1000); + grams = lrint(number * 1000); break; case units::LBS: grams = lbs_to_grams(number); @@ -870,13 +870,13 @@ int parsePressureToMbar(const QString &text) return 0; double number = numOnly.toDouble(); if (text.contains(QObject::tr("bar"), Qt::CaseInsensitive)) { - mbar = rint(number * 1000); + mbar = lrint(number * 1000); } else if (text.contains(QObject::tr("psi"), Qt::CaseInsensitive)) { mbar = psi_to_mbar(number); } else { switch (prefs.units.pressure) { case units::BAR: - mbar = rint(number * 1000); + mbar = lrint(number * 1000); break; case units::PSI: mbar = psi_to_mbar(number); @@ -1242,8 +1242,8 @@ extern "C" void picture_load_exif_data(struct picture *p) goto picture_load_exit; if (exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size) != PARSE_EXIF_SUCCESS) goto picture_load_exit; - p->longitude.udeg= lrint(1000000.0 * exif.GeoLocation.Longitude); - p->latitude.udeg = lrint(1000000.0 * exif.GeoLocation.Latitude); + p->longitude.udeg= llrint(1000000.0 * exif.GeoLocation.Longitude); + p->latitude.udeg = llrint(1000000.0 * exif.GeoLocation.Latitude); picture_load_exit: free(mem.buffer); @@ -1280,7 +1280,7 @@ weight_t string_to_weight(const char *str) if (prefs.units.weight == prefs.units.LBS) goto lbs; kg: - weight.grams = rint(value * 1000); + weight.grams = lrint(value * 1000); return weight; lbs: weight.grams = lbs_to_grams(value); @@ -1305,7 +1305,7 @@ depth_t string_to_depth(const char *str) if (prefs.units.length == prefs.units.FEET) goto ft; m: - depth.mm = rint(value * 1000); + depth.mm = lrint(value * 1000); return depth; ft: depth.mm = feet_to_mm(value); @@ -1328,7 +1328,7 @@ pressure_t string_to_pressure(const char *str) if (prefs.units.pressure == prefs.units.PSI) goto psi; bar: - pressure.mbar = rint(value * 1000); + pressure.mbar = lrint(value * 1000); return pressure; psi: pressure.mbar = psi_to_mbar(value); @@ -1362,7 +1362,7 @@ cuft: value /= bar_to_atm(workp.mbar / 1000.0); value = cuft_to_l(value); l: - volume.mliter = rint(value * 1000); + volume.mliter = lrint(value * 1000); return volume; } @@ -1372,7 +1372,7 @@ fraction_t string_to_fraction(const char *str) double value = strtod_flags(str, &end, 0); fraction_t fraction; - fraction.permille = rint(value * 10); + fraction.permille = lrint(value * 10); /* * Don't permit values less than zero or greater than 100% */ diff --git a/core/statistics.c b/core/statistics.c index cb21961d4..b615cdef1 100644 --- a/core/statistics.c +++ b/core/statistics.c @@ -396,8 +396,8 @@ static void get_gas_parts(struct gasmix mix, volume_t vol, int o2_in_topup, volu return; } - air.mliter = rint(((double)vol.mliter * (1000 - get_he(&mix) - get_o2(&mix))) / (1000 - o2_in_topup)); - he->mliter = rint(((double)vol.mliter * get_he(&mix)) / 1000.0); + air.mliter = lrint(((double)vol.mliter * (1000 - get_he(&mix) - get_o2(&mix))) / (1000 - o2_in_topup)); + he->mliter = lrint(((double)vol.mliter * get_he(&mix)) / 1000.0); o2->mliter += vol.mliter - he->mliter - air.mliter; } diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c index 925783a6d..4a03c065e 100644 --- a/core/uemis-downloader.c +++ b/core/uemis-downloader.c @@ -92,7 +92,7 @@ static void uemis_ts(char *buffer, void *_when) /* float minutes */ static void uemis_duration(char *buffer, duration_t *duration) { - duration->seconds = rint(ascii_strtod(buffer, NULL) * 60); + duration->seconds = lrint(ascii_strtod(buffer, NULL) * 60); } /* int cm */ diff --git a/core/uemis.c b/core/uemis.c index 5635d5630..564e7dfbb 100644 --- a/core/uemis.c +++ b/core/uemis.c @@ -337,7 +337,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap) * we store the incorrect working pressure to get the SAC calculations "close" * but the user will have to correct this manually */ - dive->cylinder[i].type.size.mliter = rint(volume); + dive->cylinder[i].type.size.mliter = lrintf(volume); dive->cylinder[i].type.workingpressure.mbar = 202600; dive->cylinder[i].gasmix.o2.permille = *(uint8_t *)(data + 120 + 25 * (gasoffset + i)) * 10; dive->cylinder[i].gasmix.he.permille = 0; diff --git a/core/units.h b/core/units.h index 029bb64fa..30d52fbf8 100644 --- a/core/units.h +++ b/core/units.h @@ -134,7 +134,7 @@ static inline double grams_to_lbs(int grams) static inline int lbs_to_grams(double lbs) { - return rint(lbs * 453.6); + return lrint(lbs * 453.6); } static inline double ml_to_cuft(int ml) @@ -159,12 +159,12 @@ static inline double m_to_mile(int m) static inline unsigned long feet_to_mm(double feet) { - return rint(feet * 304.8); + return lrint(feet * 304.8); } static inline int to_feet(depth_t depth) { - return rint(mm_to_feet(depth.mm)); + return lrint(mm_to_feet(depth.mm)); } static inline double mkelvin_to_C(int mkelvin) @@ -179,12 +179,12 @@ static inline double mkelvin_to_F(int mkelvin) static inline unsigned long F_to_mkelvin(double f) { - return rint((f - 32) * 1000 / 1.8 + ZERO_C_IN_MKELVIN); + return lrint((f - 32) * 1000 / 1.8 + ZERO_C_IN_MKELVIN); } static inline unsigned long C_to_mkelvin(double c) { - return rint(c * 1000 + ZERO_C_IN_MKELVIN); + return lrint(c * 1000 + ZERO_C_IN_MKELVIN); } static inline double psi_to_bar(double psi) @@ -194,12 +194,12 @@ static inline double psi_to_bar(double psi) static inline long psi_to_mbar(double psi) { - return rint(psi_to_bar(psi) * 1000); + return lrint(psi_to_bar(psi) * 1000); } static inline int to_PSI(pressure_t pressure) { - return rint(pressure.mbar * 0.0145037738); + return lrint(pressure.mbar * 0.0145037738); } static inline double bar_to_atm(double bar) diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index 1cf0b911f..e4ea71445 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -379,12 +379,12 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) void PlannerSettingsWidget::updateUnitsUI() { - ui.ascRate75->setValue(rint(prefs.ascrate75 / UNIT_FACTOR)); - ui.ascRate50->setValue(rint(prefs.ascrate50 / UNIT_FACTOR)); - ui.ascRateStops->setValue(rint(prefs.ascratestops / UNIT_FACTOR)); - ui.ascRateLast6m->setValue(rint(prefs.ascratelast6m / UNIT_FACTOR)); - ui.descRate->setValue(rint(prefs.descrate / UNIT_FACTOR)); - ui.bestmixEND->setValue(rint(get_depth_units(prefs.bestmixend.mm, NULL, NULL))); + ui.ascRate75->setValue(lrint(prefs.ascrate75 / UNIT_FACTOR)); + ui.ascRate50->setValue(lrint(prefs.ascrate50 / UNIT_FACTOR)); + ui.ascRateStops->setValue(lrint(prefs.ascratestops / UNIT_FACTOR)); + ui.ascRateLast6m->setValue(lrint(prefs.ascratelast6m / UNIT_FACTOR)); + ui.descRate->setValue(lrint(prefs.descrate / UNIT_FACTOR)); + ui.bestmixEND->setValue(lrint(get_depth_units(prefs.bestmixend.mm, NULL, NULL))); } PlannerSettingsWidget::~PlannerSettingsWidget() diff --git a/desktop-widgets/globe.cpp b/desktop-widgets/globe.cpp index 39f030b74..ebe1fdb1c 100644 --- a/desktop-widgets/globe.cpp +++ b/desktop-widgets/globe.cpp @@ -140,8 +140,8 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) return; GeoDataCoordinates here(lon, lat, unit); - long lon_udeg = rint(1000000 * here.longitude(GeoDataCoordinates::Degree)); - long lat_udeg = rint(1000000 * here.latitude(GeoDataCoordinates::Degree)); + long lon_udeg = lrint(1000000 * here.longitude(GeoDataCoordinates::Degree)); + long lat_udeg = lrint(1000000 * here.latitude(GeoDataCoordinates::Degree)); // distance() is in km above the map. // We're going to use that to decide how @@ -155,7 +155,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) // Trigonometry is hard, but sin x == x // for small x, so let's just do this as // a linear thing. - long resolve = rint(distance() * 1000); + long resolve = lrint(distance() * 1000); int idx; struct dive *dive; @@ -347,8 +347,8 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U centerOn(lon, lat, true); // change the location of the displayed_dive and put the UI in edit mode - displayed_dive_site.latitude.udeg = lrint(lat * 1000000.0); - displayed_dive_site.longitude.udeg = lrint(lon * 1000000.0); + displayed_dive_site.latitude.udeg = llrint(lat * 1000000.0); + displayed_dive_site.longitude.udeg = llrint(lon * 1000000.0); emit coordinatesChanged(); repopulateLabels(); } diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp index 062f30a6f..8245e59a6 100644 --- a/desktop-widgets/preferences/preferences_graph.cpp +++ b/desktop-widgets/preferences/preferences_graph.cpp @@ -41,7 +41,7 @@ void PreferencesGraph::refreshSettings() ui->show_ccr_sensors->setChecked(prefs.show_ccr_sensors); ui->defaultSetpoint->setValue((double)prefs.defaultsetpoint / 1000.0); ui->psro2rate->setValue(prefs.o2consumption / 1000.0); - ui->pscrfactor->setValue(rint(1000.0 / prefs.pscr_ratio)); + ui->pscrfactor->setValue(lrint(1000.0 / prefs.pscr_ratio)); ui->display_unused_tanks->setChecked(prefs.display_unused_tanks); ui->show_average_depth->setChecked(prefs.show_average_depth); @@ -50,9 +50,9 @@ void PreferencesGraph::refreshSettings() void PreferencesGraph::syncSettings() { auto general = SettingsObjectWrapper::instance()->general_settings; - general->setDefaultSetPoint(rint(ui->defaultSetpoint->value() * 1000.0)); - general->setO2Consumption(rint(ui->psro2rate->value() *1000.0)); - general->setPscrRatio(rint(1000.0 / ui->pscrfactor->value())); + general->setDefaultSetPoint(lrint(ui->defaultSetpoint->value() * 1000.0)); + general->setO2Consumption(lrint(ui->psro2rate->value() *1000.0)); + general->setPscrRatio(lrint(1000.0 / ui->pscrfactor->value())); auto pp_gas = SettingsObjectWrapper::instance()->pp_gas; pp_gas->setPheThreshold(ui->pheThreshold->value()); diff --git a/mobile-widgets/qmlprofile.cpp b/mobile-widgets/qmlprofile.cpp index b023741ef..d75504ec6 100644 --- a/mobile-widgets/qmlprofile.cpp +++ b/mobile-widgets/qmlprofile.cpp @@ -37,7 +37,7 @@ void QMLProfile::paint(QPainter *painter) qreal sy = painterRect.height() / sceneSize / dprComp; // next figure out the weird magic by which we need to shift the painter so the profile is shown - int dpr = rint(devicePixelRatio()); + int dpr = lrint(devicePixelRatio()); qreal magicShiftFactor = (dpr == 2 ? 0.25 : (dpr == 3 ? 0.33 : 0.0)); // now set up the transformations scale the profile and diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index a197580b1..d4899232b 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -949,8 +949,8 @@ void ProfileWidget2::mouseDoubleClickEvent(QMouseEvent *event) if (isPointOutOfBoundaries(mappedPos)) return; - int minutes = rint(timeAxis->valueAt(mappedPos) / 60); - int milimeters = rint(profileYAxis->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); + int minutes = lrint(timeAxis->valueAt(mappedPos) / 60); + int milimeters = lrint(profileYAxis->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); plannerModel->addStop(milimeters, minutes * 60, -1, 0, true); } } @@ -1789,13 +1789,13 @@ void ProfileWidget2::recreatePlannedDive() if (index < plannerModel->size() - 1) maxtime = plannerModel->at(index + 1).time; - int minutes = rint(timeAxis->valueAt(activeHandler->pos()) / 60); + int minutes = lrint(timeAxis->valueAt(activeHandler->pos()) / 60); if (minutes * 60 <= mintime || minutes * 60 >= maxtime) return; divedatapoint data = plannerModel->at(index); - data.depth = rint(profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); - data.time = rint(timeAxis->valueAt(activeHandler->pos())); + data.depth = lrint(profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); + data.time = lrint(timeAxis->valueAt(activeHandler->pos())); plannerModel->editStop(index, data); } diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 616f1dadc..46326c678 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -241,7 +241,7 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const case CCSETPOINT: return (double)p.setpoint / 1000; case DEPTH: - return (int) rint(get_depth_units(p.depth, NULL, NULL)); + return (int) lrint(get_depth_units(p.depth, NULL, NULL)); case RUNTIME: return p.time / 60; case DURATION: |