Translate unit by an offset

saf_offset_unit is a function defined in unit.c.

Synopsis:

int saf_offset_unit(SAF_ParMode pmode, SAF_Unit *unit, double offset)

Formal Arguments:

  • unit: The unit which is being translated by offset.
  • offset: The amount by which to translate the unit.

Description: Some units of measure have a scale which is translated from the origin by some amount. The most notable examples are absolute degrees Celsius and Fahrenheit.

1
2
3
 SAF_Unit absC = saf_declare_unit("Celsius","absC");
 SAF_multiply_unit(absC, 1, kelvin, 1);
 SAF_offset_unit(absC, 273.15);

Preconditions:

  • pmode must be valid. (low-cost)
  • unit must be a valid unit handle. (low-cost)
  • unit must not have a logarithm base assigned (the default). (low-cost)

Return Value: This function returns some non-negative value on success; otherwise, it either returns a negative value or raises an exception, depending on the error handling property of the library.

See Also:

  • Units: Introduction for current chapter