mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Use "rint()" instead of rounding manually with "+ 0.5"
rint() is "round to nearest integer", and does a better job than +0.5 (followed by the implicit truncation inherent in integer casting). We already used 'rint()' for values that could be negative (where +0.5 is actively wrong), let's just make it consistent. Of course, as is usual for the messy C math functions, it depends on the current rounding mode. But the default round-to-nearest is what we want and use, and the functions that explicitly always round to nearest aren't standard enough to worry about. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7ae05b4f71
commit
23baf20f56
8 changed files with 38 additions and 38 deletions
2
dive.c
2
dive.c
|
@ -549,7 +549,7 @@ static void sanitize_cylinder_type(cylinder_type_t *type)
|
|||
volume_of_air = cuft_to_l(type->size.mliter);
|
||||
/* milliliters at 1 atm: "true size" */
|
||||
volume = volume_of_air / surface_volume_multiplier(type->workingpressure);
|
||||
type->size.mliter = volume + 0.5;
|
||||
type->size.mliter = rint(volume);
|
||||
}
|
||||
|
||||
/* Ok, we have both size and pressure: try to match a description */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue