Units of Measure
Five feet and five meters are not equal even though they are both represented by the number five. Similarly, three feet and one yard are equal even though they are represented by different numbers. A numeric value alone does not fully capture the magnitude of whatever value the number is intended to represent. There is always an implied unit of measure.
You can make mathematical calculations less prone to error and simplify calculations by explicitly assigning units to numeric values. For example, the expression 3+1 produces the result 4. However, 3ft+1yd produces the result 6 ft. DScript knows how to convert yards to feet; so, it can add the quantities properly.
Using units has the following advantages:
- There is no need to convert dissimilar quantities to a common base before performing calculations.
- DScript checks calculations involving units to verify they make logical sense.
- Units make results easier to understand.
These advantages are best illustrated by the following example.
Suppose you want to know how much it costs to buy a parcel of land that measures 400 feet by 600 feet at a price of $12,000 per acre.
The lot size is given in feet while the price is given in per acre units. DScript automatically converts the lot size to acres before multiplying by the price per acre; you do not need to know how many square feet there are in an acre because DScript already knows this.
You know the result you seek should be in units of dollars because you are searching for a cost. Since the result has the units you expect, you can be certain your math is logically correct. If you had mistakenly attempted to add Lot Size and Price Per Acre, DScript would have given you an error message because this operation makes no sense. If you had attempted to divide Lot Size and Price Per Acre, the result would have units of m^4/$, clearly incorrect.
Units of measure can be enormously valuable in performing error-free calculations.
To assign units to a value, multiply the value by its unit or combination of units. For example, type $12000 per acre as 12000*$/acre (all units, including $, display after the quantity they modify). Similarly, you can type 60 miles per hour as 60*mi/hr or simply 60mph.
Note: You may omit the Multiply operator following numbers (60mph is equivalent to 60*mph). However, you must include the operator following node names (x*mph, not xmph).
See Multiply.