mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:53:23 +00:00
cleanup: fix narrowing type conversion warning
In pscr_o2() the result of a double calculation was implicitly converted to int, which resulted in a gcc warning. Part of the expression was explicitly converted to int, but then subtracted from a double. Instead, do all the calculations in double and cast the final expression to int. This is probably the prudent thing to do. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
4458535265
commit
d89ef3d906
1 changed files with 4 additions and 2 deletions
|
@ -98,8 +98,10 @@ fraction_t get_gas_component_fraction(struct gasmix mix, enum gas_component comp
|
|||
|
||||
// O2 pressure in mbar according to the steady state model for the PSCR
|
||||
// NB: Ambient pressure comes in bar!
|
||||
int pscr_o2(const double amb_pressure, struct gasmix mix) {
|
||||
int o2 = get_o2(mix) * amb_pressure - (int)((1.0 - get_o2(mix) / 1000.0) * prefs.o2consumption / (prefs.bottomsac * prefs.pscr_ratio) * 1000000);
|
||||
int pscr_o2(const double amb_pressure, struct gasmix mix)
|
||||
{
|
||||
int o2 = (int)(get_o2(mix) * amb_pressure -
|
||||
(1.0 - get_o2(mix) / 1000.0) * prefs.o2consumption / (prefs.bottomsac * prefs.pscr_ratio) * 1000000);
|
||||
if (o2 < 0.0) // He's dead, Jim.
|
||||
o2 = 0.0;
|
||||
return o2;
|
||||
|
|
Loading…
Add table
Reference in a new issue