Zerksis D. Umrigar
447 Plaza Dr., 5-57, Vestal NY 13850
(607) 729-5919
Email: umrigar@cs.binghamton.edu
Dimensional analysis is widely used by those involved in the physical sciences as a quick check on the dimensional sanity of formulas. Many programming errors can be prevented by performing similar checks automatically. Previous attempts at such dimensional analysis of computer programs either entailed some run-time overhead [CG88] [Hil88], or required the modification of an existing programming language to add such a capability [Geh77] [Hou83]. This paper describes how an existing language C++\ [Str91] can be used to write programs which can be guaranteed to be dimensionally correct before run-time. Unfortunately, the method depends on a language construct which violates the language definition. The paper argues that the rule forbidding the construct be removed from the language definition, or that the forbidden construct be allowed as an extension by most compilers. In fact, a popular C++ compiler does accept this construct. This compiler was used to implement a general package for dimensional analysis. The capabilities of the package are briefly illustrated by means of an example. Ultimately, the method should have negligible run-time costs.