Your second-grade teacher must have told you that you cannot compare a pound of apples with a pound of oranges. This may have been your first encounter with the concept of dimensions. Some years later, your Physics 101 professor probably mentioned that you cannot directly compare speed measured in furlongs per fortnight to speed measured in miles per hour. She was talking about units.
The concepts of dimensions, things that can be measured and units, and ways to express these measurements play a central role in science, engineering, and other areas of life. Indeed, it is a well-publicized fact that incompatible units can lead to disaster, such as the loss of the Mars orbiter in 1999 due to confusion at NASA between the metric system and the English system.
Many modern programming languages, including Java, ignore units and dimensions, treating numbers as being dimensionless. This gives developers the freedom to mistakenly turn feet into pounds, just as years ago, in the days of pre-ANSI C, a developer could turn a character string into meaningless floating point numbers with no warning. JSR-108, the main subject of this article, is the Java community's attempt to tackle this issue, but before we discuss it, some definitions are in order.
A dimension is a thing that can be measured. Length, time, mass, temperature, air pressure, and velocity are all dimensions. Dimensions can be related to other dimensions using multiplication and division. For example, length equals velocity multiplied by time, regardless of how we measure them.
A unit, or unit of measurement, is a constant quantity that allows us to express measurements of a dimension -- for example, the current definition of the meter, a standard unit of length, is:
A meter is the length of the path traveled by light in vacuum during a time interval of 1/299,792,458 of a second.
Units can be converted into other units that measure the same dimension. For example, we can convert IPS (Instructions Per Second) into MIPS by dividing the number of IPS by 1 million. So: 7,000,000 IPS = 7 MIPS.
Units can be derived from other units, mostly by using multiplication and division. For example, the standard unit of Force can be defined as:
1 Newton = 1 Kilogram * Meter / (Second * Second)
Units are compatible or convertible if their dimensions are equal. A Newton that has dimension mass*length/time2 is therefore compatible with a Dyne (that's another unit of force), but not with a Didot point, which has a dimension of length.
Units can be aggregated to form systems of units, which allow us to measure all of the dimensions in which we are interested. The standard system of physical units is known as SI and deals with mass, time, length, electric current, amount of material, and a couple of other physical dimensions. Newtons and meters are part of SI, while degrees Fahrenheit and inches (and, for that matter, Furlongs and Didot points) are not.
Finally, there exist dimensionless quantities, which have no dimension (or have the identity dimension). Seven, as such, is a dimensionless quantity.
JSR-108
The Java Units Specification, initiated in early 2001, is an attempt at introducing physical units and dimensions to the language. At its base were two reference-unit frameworks (see References), both developed by Steven Emmerson, who is also the JSR-108 specification lead. A concrete implementation for physical units was later developed by Jean-Marie Dautelle as part of the noteworthy J.A.D.E. package. JSR-108 introduces classes that support:
* Checking unit compatibility.
* Numeric value conversion.
* Scaling and other arithmetic operations on units.
* Implementation of standard units (e.g., units that are part of SI).
* Unit parsers for standard specification formats.
Answered by
Om Prakash
, an ibibo Master,
at
6:04 PM on November 04, 2008