units icon indicating copy to clipboard operation
units copied to clipboard

Better output of compound units?

Open le-migou opened this issue 7 years ago • 3 comments

In v3.0.0.alpha-2, this

auto P = 1_MPa;
std::cout << P << '\n';

gives

1e+06 m^-1 kg s^-2

. Wouldn't something like

std::cout << P.value () << ' ' << abbreviation (P) << '\n';

that produces

1 MPa

be preferable ?

le-migou avatar Jul 03 '18 08:07 le-migou

Seems like a bug that it doesn't print the latter. If it has an UDL, then the abbreviation should be printed. But your output suggests that the streaming operator for ephemeral units is being used.

JohelEGP avatar Jul 04 '18 02:07 JohelEGP

definitely a bug.

nholthaus avatar Jul 04 '18 14:07 nholthaus

Seems like #146 and this were fixed by #167, so in the v3.x branch the output is as expected. -- https://github.com/nholthaus/units/issues/195#issuecomment-429398567

JohelEGP avatar Oct 06 '20 02:10 JohelEGP