units of measure : Java Glossary
home U words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish 2007-10-29 by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
units of measure
One of the most common errors in engineering programming is making invalid assumptions about the units of measure of a variable. Is the force measured in newtons or pounds? If the units of measure were explicitly stated, then dimensionality consistency checks could automatically be done on assignment and expressions. You can’t assign a variable measured in kiloPascals to one measured in joules. You can’t add seconds to kilograms. The compiler could even put in conversion factors when the units don’t quite match, so long as the dimensionality is correct. e.g. assign a miles/hour value to a km/hour variable, or perhaps even a miles/gallon value to a liters/km variable.

What is dimensionality? You can think of any unit of measure as distanced x massm x timet for some positive or negative integers d, m and t. For example speed = distance × time-1. The dimensionality of a unit of measure is that tuple: d, m and t.

The same notion can apply to units of measure in business programming, e.g. does variable size measure rows or columns? It is dangerous to get it backwards. If the units of measure were formally declared, the compiler could catch you if you used the variable in the wrong context.

Some people have suggested piggybacking a scheme for checking units of measure atop Java. Others want to go further and have automatic conversions applied.


CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.16] Spread the Net
You are visitor number 7,774.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/unitsofmeasure.html J:\mindprod\jgloss\unitsofmeasure.html