51 offsetBeforeFactor =
true;
65 float defaultValue = std::nanf(
"1"),
66 bool offsetBeforeFactor =
true,
67 const char* nameForDebugging =
"")
81 float defaultValue = std::nanf(
"1"),
82 bool offsetBeforeFactor =
true,
83 const char* nameForDebugging =
"")
86 const auto rawAsInt =
reinterpret_cast<std::uint64_t
>(raw);
88 <<
"\nThe alignment is wrong!\nIt has to be " <<
alignof(
T)
89 <<
", but the data is aligned with " << rawAsInt %
alignof(std::max_align_t)
90 <<
"!\nThis is an offset of " << (rawAsInt %
alignof(
T))
91 <<
" bytes!\nThe datatype is " << GetTypeString<T>() <<
"\nIts size is "
92 <<
sizeof(
T) <<
"\nraw = " << raw <<
" bytes\nThe name is " << nameForDebugging;
94 this->offsetBeforeFactor = offsetBeforeFactor;
95 this->factor = factor;
96 this->offset = offset;
98 if (!std::isnan(defaultValue))
100 value = defaultValue;
113 if (offsetBeforeFactor)
115 value = ((*raw) + offset) * factor;
119 value = (*raw) * factor + offset;
126 if (offsetBeforeFactor)
128 *raw =
static_cast<T>((
value / factor) - offset);
132 *raw =
static_cast<T>((
value)-offset) / factor;
159 return offsetBeforeFactor;
164 float offset, factor;
165 bool offsetBeforeFactor;