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