Skip to content

Priority of prefix and exponent for units is not according to the standard #1586

@kbirken

Description

@kbirken

Using the SI-unit-library (org.iets3.core.expr.typetags.phyunits.si) of the current unit language org.iets3.core.expr.typetags.physunits (see documentation), the combination of prefixes and exponents is behaving wrong.

Example: When typing "mm^2", one expects to define unit "square millimeters". However, the editor binds the exponent first and the prefix last, so the result is "milli squaremeters", which is different with a factor of 1000.

The SI Brochure (9th edition) from the BIPM states in chapter 3 on page 143:

The grouping formed by a prefix symbol attached to a unit symbol constitutes a new
inseparable unit symbol (forming a multiple or sub-multiple of the unit concerned) that can
be raised to a positive or negative power and that can be combined with other unit symbols
to form compound unit symbols.

So the prefixes should bind stronger than the exponents. The SI Brochure gives some examples:

Image

The physunits implementation (and the SI-unit-library) should be fixed, so that the standard is supported. In practice, the current behaviour leads to unexpected results without making the user aware of this pitfall.


Here is a test case showing the wrong milli-square-meter, the not really working square-millimeter, and a manual sqmm implementation.

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions