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

Format general Magnitudes in printed output

Open chiphogg opened this issue 1 year ago • 2 comments

Now that we are using Magnitude, not ratio, we need to decide how a Magnitude should be printed, and then implement that policy. We'll need to take into account, among perhaps other considerations:

  • Factoring out powers of 10
  • Irrational factors, such as (powers of) pi
  • Radical powers of integer factors

I don't know what the policy should be, but step one is to figure that out, and step two is to implement it.

(I don't have time right now to work on this, but I thought it important to have an issue to track the pending work and provide a home for discussion.)

chiphogg avatar Aug 06 '22 20:08 chiphogg

I agree with the points above. The units should be printed in terms of powers of 10 rather than a power of 2 and 5. This is connected to #377, and actually, after the refactoring of the type also to be the power of 10, the printing part should be trivial.

mpusz avatar Aug 07 '22 08:08 mpusz

Both FMT and ostream approach should be checked. At least ostreams will fail to compile for pi-based units as they use as_ratio which requires is_rational.

mpusz avatar Aug 31 '22 19:08 mpusz