Strange unit conversions

Jan Schubert Jan.Schubert at GMX.li
Wed Feb 20 01:29:59 PST 2013


Looks like normal rounding behaviour to me (not checking the numbers itself).

Jan

jukka.lind at kolumbus.fi wrote:

>Pressure unit conversions in dive.h seem strange to me.
>What is the meaning of  "0.5" in psi_to_mba and int to_PS ? If they're
>there to minimize rounding error when moving from integer to real,
>shouldn't they be before the multiplying ?
>The error at normal tank pressures is minimal and at 1 bar just about 3
>%, but anyhow.
>
> 191 static inline unsigned long psi_to_mbar(double psi)
> 192 {
> 193         return psi_to_bar(psi)*1000 + 0.5;
> 194 }
> 195 
> 196 static inline int to_PSI(pressure_t pressure)
> 197 {
> 198         return pressure.mbar * 0.0145037738 + 0.5;
> 199 }
>
>
>Sorry I haven't the "development environment" set up yet.
>Signed-off-by: Jukka Lind <lino at iki.fi>
>
>_______________________________________________
>subsurface mailing list
>subsurface at hohndel.org
>http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130220/14aca11b/attachment.html>


More information about the subsurface mailing list