Describe the bug
The filesizeformat filter internally uses f32. Unfortunately, that's not accurate enough for many common values.
To Reproduce
Add the following 2 assertions to the unit-test test_filesizeformat():
assert_eq!(filesizeformat(300.0 * 1000.0 * 1000.0 * 1000.0).unwrap().to_string(), "300 GB");
assert_eq!(filesizeformat(600.0 * 1000.0 * 1000.0 * 1000.0).unwrap().to_string(), "600 GB");
Result:
thread 'filters::humansize::test_filesizeformat' panicked at askama/src/filters/humansize.rs:124:5:
assertion `left == right` failed
left: "299.99 GB"
right: "300 GB"
Now, I could just replace f32 with f64. That makes it go away, but I don't know if that change makes every case go away. And since it looks rather ... optimized, I don't really dare to touch it.
Describe the bug
The
filesizeformatfilter internally usesf32. Unfortunately, that's not accurate enough for many common values.To Reproduce
Add the following 2 assertions to the unit-test
test_filesizeformat():Result:
Now, I could just replace
f32withf64. That makes it go away, but I don't know if that change makes every case go away. And since it looks rather ... optimized, I don't really dare to touch it.