mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add helper function for doing depth unit calculations
.. and use it for printing too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
184eecf7c0
commit
515a917152
4 changed files with 37 additions and 17 deletions
25
dive.c
25
dive.c
|
@ -5,6 +5,31 @@
|
|||
|
||||
#include "dive.h"
|
||||
|
||||
double get_depth_units(unsigned int mm, int *frac, const char **units)
|
||||
{
|
||||
int decimals;
|
||||
double d;
|
||||
const char *unit;
|
||||
|
||||
switch (output_units.length) {
|
||||
case METERS:
|
||||
d = mm / 1000.0;
|
||||
unit = "m";
|
||||
decimals = d < 20;
|
||||
break;
|
||||
case FEET:
|
||||
d = mm_to_feet(mm);
|
||||
unit = "ft";
|
||||
decimals = 0;
|
||||
break;
|
||||
}
|
||||
if (frac)
|
||||
*frac = decimals;
|
||||
if (units)
|
||||
*units = unit;
|
||||
return d;
|
||||
}
|
||||
|
||||
struct dive *alloc_dive(void)
|
||||
{
|
||||
const int initial_samples = 5;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue