pub fn float_to_weight(f: f64) -> (u32, u32)
Expand description

Convert a floating-point weight in the range (0.0,1.0) to a pair of weights that can be used with Union and similar.

The first return value is the weight corresponding to f; the second return value is the weight corresponding to 1.0 - f.

This call does not make any guarantees as to what range of weights it may produce, except that adding the two return values will never overflow a u32. As such, it is generally not meaningful to combine any other weights with the two returned.

Panics

Panics if f is not a real number between 0.0 and 1.0, both exclusive.