[PATCH] centralised definition for surface pressure
torvalds at linux-foundation.org
Mon Jan 14 12:45:38 PST 2013
On Mon, Jan 14, 2013 at 9:52 AM, Dirk Hohndel <dirk at hohndel.org> wrote:
>> +#define O2_IN_AIR 0.20942
>> +#define AIR_PERMILLE O2_IN_AIR * 1000
> Now this is interesting. I'm not sure this will bite us anywhere in the
> code, but if you think about it, the old definition of 209 was an int,
> but 0.20942 * 1000 is actually a float. So this could change calculations.
> So while I like the intent of making this simpler, I think I'd feel
> better if AIR_PERMILLE was defined to be 209 in stead of 0.20942 * 1000
I have a more fundamental disagreement with the patch.
Which is that the precision of the constant is overengineered to begin
with. We're not trying to estimate the weight of all the oxygen in the
atmosphere to the nearest ton.
None of the calculations involved care at *all* about that kind of
precision. I can pretty much guarantee that you could use 20/80 for
O2/N2 and get the numbers right with *one* significant digit. 21/78 is
fine too. Even 209 permille was actually largely because I consciously
wanted to avoid using the round 21% number, so that it would stand out
if we saved it in the xml file.
Using five significant digits is just over-the-top.
So I agree with Dirk, and I'd much rather use integer math and never
have to even think about rounding. But even more so, I dislike
More information about the subsurface