[PATCH] Air isn't special
Dirk Hohndel
dirk at hohndel.org
Sun Jun 1 10:37:01 PDT 2014
On Sun, Jun 01, 2014 at 10:27:09AM -0700, Linus Torvalds wrote:
>
> Side note: that whole cylinder mess is actually pretty similar to what
> you are proposing, and for exactly the same reasons: wanting to have
> an explicit value where an explicit value wasn't really a good idea.
>
> The fact is, we're better off just leaving things as "empty" (zero or
> NULL or whatever else is appropriate) and considering them
> uninitialized and neither loaded nor saved. Then, those empty fields
> can have default values when displayed or used. For some things (like
> temperature), they mean "don't know/exist". For other things, like gas
> contents, zero means "air". For yet other things, it can mean "use the
> defaults from the config".
Yes - you mentioned before that you'd prefer to have the cyl->used thing
calculated on the fly. It's a somewhat expensive thing to do so having the
cached value seemed useful, but I can go back and look at that.
> Side note: if get_o2() were to be changed to also do the type
> conversion away from permille, that would probably be a good idea.
> Right now we have actively bogus math like
>
> depth.mm = po2_limit.mbar * 1000 / get_o2(mix) * 10 - 10000;
>
> which does rounding wrong, and only works on a centimeter scale anyway
> (see the "* 10" in the wrong place - after the division that doesn't
> round).
>
> Of course, it doesn't really matter if our depth estimate might be
> wrong by one centimeter, so nobody *cares*, but we might actually be
> better off just saying
>
> (a) if you want to use O2 percentages in actual _calculations_, you
> should use "get_o2()" which does it as a floating point value (either
> percent or perhaps just as a fraction of 1, which is what you'd
> probably mostly want for calculations)
>
> (b) if you want to *show* the O2 percentage, then get the permille
> value, show "0" as air, and do the proper exact integer
> FRACTION(o2,10) thing to get the "decimal" value.
>
> those are actually sane and simple rules.
That does seem sane. Given it's late in the Linux cycle, do you have the
time to send a patch that consistently does that everywhere?
/D
More information about the subsurface
mailing list