mp-units icon indicating copy to clipboard operation
mp-units copied to clipboard

Units text output (standard vs engineering)

Open mpusz opened this issue 5 years ago • 5 comments

ISO 80000 explicitly states that:

When symbols for quantities are combined in a product of two or more quantities, this combination is indicated in one of the following ways: ab, a b, a · b, a × b.

Here is the example of how it looks in practice:

image

Because of the above, we chose to print a · b for Standard Mode and a b for ASCII mode. Both cases inject spaces in the unit symbol which makes the output hard to parse.

Should we prefer standard compliance or engineering sanity here?

mpusz avatar Mar 28 '20 11:03 mpusz

I admit that a · b with monospace font looks bad :-(

mpusz avatar Mar 28 '20 11:03 mpusz

Also, rediscuss:

  • Standard Mode as the default one (instead of ASCII)
  • if %Aq modifier is enough to switch to ASCII or if there should be some global switch to do it?

mpusz avatar Mar 28 '20 11:03 mpusz

This document leaves hope that we can get rid of spaces at least for a Standard Format:

mpusz avatar Mar 28 '20 16:03 mpusz

This is probably more about input than output. IOW how easy is it to read a quantity back from a stream.

Here is an example in my quan library, which admittedly doesnt raise the bar that high, but may provide a place to start.

https://github.com/kwikius/quan-trunk/blob/master/quan_matters/examples/input.cpp.

My issue with spaces is that you move from lexing to parsing. Is the grammar LL1 https://en.wikipedia.org/wiki/LL_parser. Then you need to provide a parser

kwikius avatar Mar 29 '20 10:03 kwikius

Note to myself: another subject to discuss with ISO is #59.

mpusz avatar Mar 31 '20 07:03 mpusz

I removed the extra spaces some time ago. The SI brochure does not seem to provide additional spaces in its example, and it was just too ugly.

mpusz avatar Sep 11 '22 07:09 mpusz