40 m_fraction(static_cast<uint8_t>(f * UINT8_MAX)) {
41 assert((0
u < e) and (
"The atomic number must be positive"));
42 assert((0.0f <= f) and (f <= 1.0f) and
43 "Relative fraction must be in [0,1]");
52 assert((0
u < e) and (
"The atomic number must be positive"));
53 assert((w < 256
u) and
"Integer weight must be in [0,256)");
68 return static_cast<float>(
m_fraction) / UINT8_MAX;
104 total += element.m_fraction;
107 float scale = float(UINT8_MAX) / float(total);
108 for (
auto& element : m_elements) {
109 element.m_fraction *=
scale;