diff options
author | Robert C. Helling <helling@atdotde.de> | 2017-03-10 07:22:31 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-03-11 08:03:25 -0800 |
commit | 295b1b78d888b528f7a5a23411b1a82d4b39eed1 (patch) | |
tree | e41ef5bb9fcfbdec3c536be1cb653faac047d81e /core/dive.c | |
parent | af96ec5d04b09a87696b3f292bc5ad5378d26f75 (diff) | |
download | subsurface-295b1b78d888b528f7a5a23411b1a82d4b39eed1.tar.gz |
Make depth conversion work for negative depths
This is needed in the altitude pressure conversion as there
negative altitudes are possible (for diving in the netherlands
or the Dead Sea).
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/dive.c')
-rw-r--r-- | core/dive.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/core/dive.c b/core/dive.c index 48dd929f4..b091e2bc7 100644 --- a/core/dive.c +++ b/core/dive.c @@ -248,11 +248,15 @@ int units_to_sac(double volume) return rint(volume * 1000); } -unsigned int units_to_depth(double depth) +depth_t units_to_depth(double depth) { - if (get_units()->length == METERS) - return rint(depth * 1000); - return feet_to_mm(depth); + depth_t internaldepth; + if (get_units()->length == METERS) { + internaldepth.mm = rint(depth * 1000); + } else { + internaldepth.mm = feet_to_mm(depth); + } + return internaldepth; } double get_depth_units(int mm, int *frac, const char **units) |