Units of measurement for Ada v3.0

If you need to handle dimensioned values, the Units of measurement for Ada v3.0 might just be what you need.

This latest version contains exactly one change compared to the previous version:

  • Output of exact zero values uses power 1 with any small. E.g. 0W is output as 0 W rather than 0 yW

Here’s a blurb about the library:

The need of support for handling measurement units does not require any approval. It is in particular true for the Ada programming language with its stress on safety and maintainability. The proposed set of packages represents a possible solution of the unit problem. Dimension checking is performed at run-time, so performance is sacrificed for safety. However, an attempt was made to reduce performance hit. The type Measure used to represent dimensioned values can be constrained to a specific unit. Operations on constrained subtypes of Measure could be potentially as efficient as floating-point operations. They are declared inlined, so that at least theoretically, a decent compiler could perform discriminant calculation and check at compile time.

You can read the full announcement here.

Leave a Reply