config-rs
config-rs copied to clipboard
Floats in configuration probably shouldn't round to integers if theres precision loss
Currently when you Config::get
an integer and config has a float specified, the config-rs
crate will transparently lose the precision, potentially leading to unexpected behaviour. For instance:
frame_rate = 59.94
will transparently round up to 60, potentially giving wrong video. There are probably many more instances where loss of precision can give very invalid results.
I believe the relevant code is probably this line.
I saw a number of FIXME
s in the codebase around not succeeding when integer wraparound occurs. We most likely can utilize something similar here – if converting results in loss of precision, fail.
Agreed. Also, the crate stores u8 in u64 (and so on), which should be fixed as well (mentioning it here because it falls into the same category of issues).