Pārlūkot izejas kodu

Fix a rounding error in human readable filesizes

ariasuni 4 gadi atpakaļ
vecāks
revīzija
74ecf6d311
1 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 3 3
      src/output/render/size.rs

+ 3 - 3
src/output/render/size.rs

@@ -41,9 +41,9 @@ impl f::Size {
         };
         };
 
 
         let symbol = prefix.symbol();
         let symbol = prefix.symbol();
-        let number = if n < 10_f64 { numerics.format_float(n, 1) }
-                              else { numerics.format_int(n as isize) };
-
+        let decimal_to_diplay = if n < 10_f64 { 1 } else { 0 };
+        let number = numerics.format_float(n, decimal_to_diplay);
+        
         // The numbers and symbols are guaranteed to be written in ASCII, so
         // The numbers and symbols are guaranteed to be written in ASCII, so
         // we can skip the display width calculation.
         // we can skip the display width calculation.
         let width = DisplayWidth::from(number.len() + symbol.len());
         let width = DisplayWidth::from(number.len() + symbol.len());