-
Notifications
You must be signed in to change notification settings - Fork 67
Description
What is your question?
I'm trying to find a concrete example or documentation on how to use cnl::from_rep
. The doygen documentation is not particularly helpful in this regard, and the unit tests are not examples. The examples in the doxygen docs, while clear enough, do not seem to cover this case. Knowing that cnl::from_rep
is a functor does not, in of itself, particularly useful without some additional documentation about its use. from_value
is mentioned in the doxygen docs, but does not seem to exist.
Anything you're curious about related to CNL.
What are you trying to do?
Among other things, I'm trying to convert from the underlying integer type to a cnl::scaled_integer
for serialization / deserialization. cnl::to_rep()
is straightforward enough, but I need to construct a cnl::scaled_integer
from its representation, as that's what is being serialized.
In addition, I'm trying to do some integer math with values that already represent fractional amounts corresponding to the LSB of the scaled_integer
.
At one point, I was able to do what seemed to work:
using FractionalKilopascals = cnl::scaled_integer<int32_t, cnl::power<-3>>;
and then do a conversion with..
constexpr int16_t value = 1;
constexpr auto oneEighth = cnl::from_rep<FractionalKilopascals , int16_t> {}(value);
Another possible way to do this might be through multiplication, which one hopes optimizes out...
constexpr auto anotherEighth = FractionalKilopascals(0.125f) * value;
What environment are you working in?
Arm Cortex embedded for actual application, Linux and windows x64 for my own unit test cases.
Before you thought to ask this question,
what source(s) of information -- if any -- were you following?
web site / FAQ.