Associates a unit of measure with a specific quantity

saf_quantify_unit is a function defined in unit.c.

Synopsis:

int saf_quantify_unit(SAF_ParMode pmode, SAF_Unit *unit, SAF_Quantity *quantity, double scale)

Formal Arguments:

  • unit: The unit whose quantity information is being set.
  • quantity: The quantity which this unit measures.
  • scale: This argument can be used to defined a new unit as some scale of the base unit for the quantity without requiring the unit definition to include a multiplication by the base unit. The scale is multiplied into any scale which is already present.

Description: A basic unit is a unit which measures an arbitrary amount of some quantity, and is defined simply by associating the unit with its quantity by calling this function. (no multiplications by other units are necessary).

Derived units are built by multiplying together powers of one or more other units. If just one unit is multiplied into the new definition then the new definition will refer to the same specific quantity as the unit on which it is based (if the power is one). Otherwise, when units are multiplied together the quantity measured by the product is different than the quantity measured by any of the multiplicands. When this happens it may be necessary for the client to call this function to associate a specific quantity with this new unit (it is not necessary if the library can deduce the specific quantity unambiguously from the unit’s database).

Preconditions:

  • pmode must be valid. (low-cost)
  • unit must be a valid unit handle. (low-cost)
  • quantity must be a valid quantity handle. (low-cost)
  • scale must be positive. (low-cost)

Return Value: A non-negative value is returned on success; otherwise either a negative value is returned or an exception is raised, depending on the error handling property of the library.

See Also:

  • Units: Introduction for current chapter