"Strong typing vs. strong testing"

Keith Thompson kst-u at mib.org
Tue Sep 28 21:15:07 CEST 2010

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.

>                              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).

Keith Thompson (The_Other_Keith) kst-u at mib.org  <http://www.ghoti.net/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

More information about the Python-list mailing list