refactor: quick maths
This commit is contained in:
parent
bfd278abbe
commit
2c256cf904
1 changed files with 2 additions and 7 deletions
|
|
@ -235,13 +235,8 @@ impl<T: Clone> fmt::Display for Backup<T> {
|
||||||
// Pretty-print size
|
// Pretty-print size
|
||||||
// If your backup is a petabyte or larger, this will crash and you need to re-evaluate your
|
// If your backup is a petabyte or larger, this will crash and you need to re-evaluate your
|
||||||
// life choices
|
// life choices
|
||||||
let mut index = 0;
|
let index = self.size.ilog(1024) as usize;
|
||||||
let mut size = self.size as f64;
|
let size = self.size as f64 / (1024.0_f64.powi(index as i32));
|
||||||
|
|
||||||
while size >= 1024.0 {
|
|
||||||
index += 1;
|
|
||||||
size /= 1024.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue