mpusz / mp-units

The quantities and units library for C++
https://mpusz.github.io/mp-units/
MIT License
998 stars 79 forks source link

Proper output of 8-bit values #470

Closed tobylorenz closed 1 year ago

tobylorenz commented 1 year ago

Feeding 8-bit values into std::ostream result in characters rather than numbers. Fix this by enforcing string output.

tobylorenz commented 1 year ago

Abstract code to show issue:

quantity<second, uint8_t> seconds;
std::cout << seconds << std::endl;
mpusz commented 1 year ago

Hi, thanks for raising the issue. However, I am not happy with the resolution. Forcing the usage of to_string for any representation type all the time is too much. I will provide an alternative fix soon.

tobylorenz commented 1 year ago

The solution might not be ideal, but as often "it works for me" ;-)

Yes, pointing it out, was my intend. Looking forward for a better solution.

mpusz commented 1 year ago

I oushed the solution yesterday with https://github.com/mpusz/mp-units/commit/7b47b2fe572fcfef638ebdd1b1311eda6bc168b4