"Strong typing vs. strong testing"
gneuner2 at comcast.net
Wed Sep 29 03:35:17 CEST 2010
On Tue, 28 Sep 2010 12:15:07 -0700, Keith Thompson <kst-u at mib.org>
>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
More information about the Python-list