diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-11-10 15:12:58 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-11-10 16:00:54 +0100 |
commit | 080bcc10fc5e1651bc31f2260ef85376a8356c0b (patch) | |
tree | 62e7d157b4892940a94f96ef61237b71b990bf38 /file.c | |
parent | 07de22a5d0d5b6aa189ea9a59951dc82fc031ba0 (diff) | |
download | subsurface-080bcc10fc5e1651bc31f2260ef85376a8356c0b.tar.gz |
gtk spinbuttons are crazy - fix possible divide-by-zero
When we fill the cylinder information in an imperial unit world, a
working pressure of zero is a special case, and forces us to use the
actual physical size of the cylinder in liter, despite the fact that
we normally would use cuft.
However, we compare that value against zero in a 'double', and in
between going through the gtk spinbutton logic, the zero we have
filled in then gets read out as some very tiny epsilon value from the
gtk spinbuttons (typically in the 10**-317 range). This causes us to
think that the zero isn't actually a zero, because gtk has done odd
things with it.
Fix this by calculating the millibar value (as an integer) first, and
check that *integer* against zero. Any crazy epsilon values will have
been rounded away, and our logic works again.
There's a good reason why subsurface does everything using integers
(ie the afore-mentioned "convert to integer millibar" etc) and doesn't
use floating point for any core data structures, only for conversion.
FP rounding and inexact behavior can be really subtle.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
0 files changed, 0 insertions, 0 deletions