"Strong typing vs. strong testing"

Paul Wallich pw at panix.com
Wed Sep 29 08:55:57 EDT 2010


On 9/29/10 6:40 AM, Pascal J. Bourguignon wrote:
> 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.
[...]
>
> 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.

And even that pales in comparison to the expansion and contraction of 
petroleum products with temperature. Compensation to standard temp is 
required in some jurisdictions but not in others...




More information about the Python-list mailing list