"Strong typing vs. strong testing"

Pascal J. Bourguignon pjb at informatimago.com
Wed Sep 29 12:40:58 CEST 2010

George Neuner <gneuner2 at comcast.net> writes:

> On Tue, 28 Sep 2010 12:15:07 -0700, Keith Thompson <kst-u at mib.org>
> wrote:
>>George Neuner <gneuner2 at comcast.net> writes:
>>> On 28 Sep 2010 12:42:40 GMT, Albert van der Horst
>>> <albert at spenarnc.xs4all.nl> wrote:
>>>>I would say the dimensional checking is underrated. It must be
>>>>complemented with a hard and fast rule about only using standard
>>>>(SI) units internally.
>>>>Oil output internal : m^3/sec
>>>>Oil output printed:  kbarrels/day
>>> "barrel" is not an SI unit.
>>He didn't say it was.  Internal calculations are done in SI units (in
>>this case, m^3/sec); on output, the internal units can be converted to
>>whatever is convenient.
> That's true.  But it is a situation where the conversion to SI units
> loses precision and therefore probably shouldn't be done.
>>>                              And when speaking about oil there isn't
>>> even a simple conversion.
>>>   42 US gallons  ?  34.9723 imp gal  ?  158.9873 L
>>> [In case those marks don't render, they are meant to be the
>>> double-tilda sign meaning "approximately equal".]
>>There are multiple different kinds of "barrels", but "barrels of oil"
>>are (consistently, as far as I know) defined as 42 US liquid gallons.
>>A US liquid gallon is, by definition, 231 cubic inches; an inch
>>is, by definition, 0.0254 meter.  So a barrel of oil is *exactly*
>>0.158987294928 m^3, and 1 m^3/sec is exactly 13.7365022817792
>>kbarrels/day.  (Please feel free to check my math.)  That's
>>admittedly a lot of digits, but there's no need for approximations
>>(unless they're imposed by the numeric representation you're using).
> I don't care to check it ... the fact that the SI unit involves 12
> decimal places whereas the imperial unit involves 3 tells me the
> conversion probably shouldn't be done in a program that wants
> accuracy.

Because perhaps you're thinking that oil is sent over the oceans, and
sold retails in barrils of 42 gallons?

Actually, when I buy oil, it's from a pump that's graduated in liters!

It comes from trucks with citerns containing 24 m³.

And these trucks get it from reservoirs of 23,850 m³.

"Tankers move approximately 2,000,000,000 metric tons" says the English
Wikipedia page...

Now perhaps it all depends on whether you buy your oil from Total or
from Texaco, but in my opinion, you're forgetting something: the last
drop.  You never get exactly 42 gallons of oil, there's always a little
drop more or less, so what you get is perhaps 158.987 liter or
41.9999221 US gallons, or even 158.98 liter = 41.9980729 US gallons,
where you need more significant digits.

__Pascal Bourguignon__                     http://www.informatimago.com/

More information about the Python-list mailing list