units icon indicating copy to clipboard operation
units copied to clipboard

Questions about change the underlying type

Open jpires opened this issue 6 years ago • 0 comments

Hello, I have a few question to you, and I hope this is the correct way of doing them. Please tell me if that is not the case, and what is the correct way.

So, I am starting the development of a new piece of software that needs to handle voltages, current, power and energy and this library would remove a lot of error that were made in the pass, as it would ensure that we don't do any wrong operations. Thanks for all the work :)

However, the hardware where we are gonna run this, it doesn't have support for floating point types.

After looking into the documentation I saw that it is possible to change the underlying type. Try to change it int using this code definition.

using volt_t = units::unit_t<units::voltage::volt, int, units::linear_scale>;
using millivolt_t = units::unit_t<units::voltage::millivolt, int, units::linear_scale>;

My issue is that when a conversion leads to data loss, e.g. millivolt_t to volt_t, there is no warning. Is it possible to enable this type of warnings for v2.3.1?

I tried to do the same thing on the branch V3.x and there it fails to compile when doing that conversion. What is the status of V3.x branch? Anymore major refactor planed?

Thanks

jpires avatar Feb 19 '19 15:02 jpires