Automatic conversion of units in a computer program

Electrical computers: arithmetic processing and calculating – Electrical digital calculating computer – Particular function performed

Reexamination Certificate

Rate now

  [ 0.00 ] – not rated yet Voters 0   Comments 0

Details

Reexamination Certificate

active

06636880

ABSTRACT:

TECHNICAL FIELD OF THE INVENTION
The present invention relates to units in computer programs, and in particular to allowing a computer program to carry units information about its constants, variables, and functions. The units information may be used to introduce conversion factors to ensure that computations in the computer program are carried out in a consistent manner in terms of primary units of the computer program. The present invention relates particularly to a method and apparatus for performing automatic conversion of units used in computer programs.
BACKGROUND ART
Computer programs typically include numerous expressions and functions to assign values to variables. These values often relate to units. Examples of such units and dimensions include meters, seconds, cubic meters, inches, kilograms, meters per second, and many more. One of the deficiencies of programming languages is that no information is kept about the units in which the values are expressed. It is taken for granted that programmers will deal with the units appropriately and without formal documentation of the units in the program.
Therefore, automatic verification of consistency of units in a program, say by a compiler, is not possible in known systems. A failure to correctly do so may lead to serious miscalculations. A simple example of this would be if an algebraic expression containing a variable or constant having units of metres per second is added to another variable or constant with units of centimetres per second or inches per second.
According to the article “NASA Reworks its Sums after Mars Fiasco” by Reichhardt, T., published in Nature, Vol. 401, Oct. 7, 1999, p. 517, the loss of NASA's Mars Climate Orbitor on Sep. 23, 1999, as it was about to enter orbit, has been attributed to a confusion between imperial and metric units.
DISCLOSURE OF THE INVENTION
It is an object of the present invention to provide a method of automatic conversion of units in a computer program.
According to a first aspect of the invention, there is provided a method of converting units in a computer program. The method comprises the steps of:
(a1) accepting as input a unit identifier for each variable used in the computer program, wherein each unit identifier comprises one or more unit elements;
(a2) accepting as input a primary unit element from each group of unit elements;
(a3) accepting as input a relation between each of the unit elements and one of the groups of unit elements and a conversion factor to the primary unit element of the group of unit elements;
(d) identifying instances of the variables in the computer program;
(e) augmenting the instances of the variables with a corresponding one of the unit identifiers; and
(f) identifying for each unit element, one of the groups of units and replacing the unit element with the primary unit identifier, multiplied with the conversion factor.
Preferably, when the computer program further includes at least one assignment statement, the method, for each assignment statement, comprises the further step of:
(h) dividing both sides of the assignment statement with the conversion factor(s) on the left hand side of the assignment statement.
Also, when the computer program includes at least one function, the method, for each function, preferably comprises the further steps of:
(a4) accepting as input a unit identifier for the function;
(a5) accepting as input a unit identifier for each parameter of the function;
(b) in a function body of the function, converting units by:
(b1) identifying instances of the variables in the function body;
(b2) augmenting the instances of the variables with a corresponding one of the unit identifiers;
(b3) identifying for each unit element, one of the groups of units and replacing the unit element with the primary unit identifier, multiplied with the conversion factor;
(b4) for each assignment statement in the function body, dividing both sides of the assignment statement with the conversion factor(s) on the left hand side of the assignment statement; and
(b5) dividing a return statement of the function body with conversion factor(s) of the unit identifier for the function;
(c1) identifying instances of arguments in function calls of the function in the computer program;
(c2) augmenting the instances of the arguments with a corresponding one of the unit identifiers; and
(c3) identifying for each unit element, one of the groups of units and replacing the unit element with the primary unit identifier, multiplied with the conversion factor.
(g1) identifying instances of the function call in the computer program;
(g2) augmenting the instances of the function call with a corresponding one of the unit identifiers; and
(g3) identifying for each unit element, one of the groups of units and replacing the unit element with the primary unit identifier, multiplied with the conversion factor.
According to a further aspect of the invention, there is provided an apparatus for converting units in a computer program. The apparatus comprises:
input means for:
accepting as input a unit identifier for each variable used in the computer program, wherein each unit identifier comprise one or more unit elements;
accepting as input a primary unit element from each group of unit elements; and
accepting as input a relation between each of the unit elements and one of the groups of unit elements and a conversion factor to the primary unit element of the group of unit elements;
means for identifying instances of the variables in the computer program;
means for augmenting the instances of the variables with a corresponding one of the unit identifiers; and
means for identifying for each unit element, one of the groups of units and replacing the unit element with the primary unit identifier, multiplied with the conversion factor.


REFERENCES:
patent: 4881189 (1989-11-01), Proctor
patent: 5216627 (1993-06-01), McClellan et al.
patent: 5657259 (1997-08-01), Davis et al.
patent: 6263353 (2001-07-01), Gross et al.
patent: 6381621 (2002-04-01), Hamilton
Reichardt, T., NASA Reworks its Sums after Mars Flasco, Nature Magazine, Oct. 7, 1999, p. 517, vol. 401.

LandOfFree

Say what you really think

Search LandOfFree.com for the USA inventors and patents. Rate them and share your experience with other people.

Rating

Automatic conversion of units in a computer program does not yet have a rating. At this time, there are no reviews or comments for this patent.

If you have personal experience with Automatic conversion of units in a computer program, we encourage you to share that experience with our LandOfFree.com community. Your opinion is very important and Automatic conversion of units in a computer program will most certainly appreciate the feedback.

Rate now

     

Profile ID: LFUS-PAI-O-3124026

  Search
All data on this website is collected from public sources. Our data reflects the most accurate information available at the time of publication.