mirror of
https://github.com/simon-ding/polaris.git
synced 2026-05-27 13:07:47 +08:00
fix number formats
This commit is contained in:
@@ -49,7 +49,7 @@ extension FileFormatter on num {
|
|||||||
final base = base1024 ? 1024 : 1000;
|
final base = base1024 ? 1024 : 1000;
|
||||||
if (this <= 0) return "0";
|
if (this <= 0) return "0";
|
||||||
final units = ["B", "kB", "MB", "GB", "TB"];
|
final units = ["B", "kB", "MB", "GB", "TB"];
|
||||||
int digitGroups = (log(this) / log(base)).round();
|
int digitGroups = (log(this) / log(base)).floor();
|
||||||
return "${NumberFormat("#,##0.#").format(this / pow(base, digitGroups))} ${units[digitGroups]}";
|
return "${NumberFormat("#,##0.#").format(this / pow(base, digitGroups))} ${units[digitGroups]}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user