[PATCH] Added support for parsing temperature in the dive header

Janice McLaughlin janice at moremobilesoftware.com
Wed Sep 10 19:46:25 PDT 2014


On Sep 10, 2014, at 7:08 PM, Linus Torvalds <torvalds at linux-foundation.org> wrote:
> On Sep 10, 2014 7:00 PM, "Janice McLaughlin" <janice at moremobilesoftware.com> wrote:
> >
> > First, my dc_tankinfo_t looks like this:
> > typedef struct dc_tankinfo_t {
> >     float helium;
> >     float oxygen;
> >     float nitrogen;
> ..
> 
> Ate these actually "float" from the dive computer?
> 
> 
No. libdivecomputer already uses the following for gasmixes:

typedef struct dc_gasmix_t {
	double helium;
	double oxygen;
	double nitrogen;
}

And converts the information from the DC (model specific but usually an integer byte) into a number between 0 and 1 for each field indicating percentage. I wanted to keep the same model but just switched from double's to float's for my app since there were many of them.

> Because we've seen bad problems with floating point values when dive log software used it. Things like saving XML files that have crazy stuff with exponents etc. Or values saved as 24.4999996 instead of 24.5 and things like that.  I think I saw this particularly with jdivelog, but maybe I misremember. It's one of the reasons that subsurface trends to try to keep things as integers (ie integer mbar instead of a floating point bar)

Indeed, I agree. And not surprising. I just thought I would (generally) stick to the same existing libdivecomputer model for code sharing (or copy and pasting) purposes.
> 
> Also, nitrogen seems very redundant.
> 
>     Linus

True. That is until libdivecomputer supports another gas, say ... hydrogen? :-) Although if consumer dive computers that support "Hydreliox" come out, I think it's time to move on! 

Janice






More information about the devel mailing list