Fix cylinder air size calculations

Linus Torvalds torvalds at
Sun Feb 24 15:33:37 PST 2013

Commit 90d3c5614a9c ("Centralising and redefining values as integers")
broke SAC-rate calculations. In particular, it changed "to_ATM()": to
use the centralized SURFACE_PRESSURE helper define, but in the process
it changed a floating point calculation to an integer calculation, and
it threw away all the fractional details. Any user of "to_ATM()"
basically dropped to an accuracy of a single atmosphere.

The good news is that we didn't use to_ATM() for things like depth
calculations, but only for cylinder pressures. As a result, the error
ends up being relatively small, since the pressures involved are big,
and thus the error of rounding to whole atmospheres is usually in the
1% range. The cylinder sizing tends to be off by more than that
anyway. But it was wrong, and not intentional.

Signed-off-by: Linus Torvalds <torvalds at>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 354 bytes
Desc: not available
URL: <>

More information about the subsurface mailing list