mirror of
https://github.com/simon-ding/polaris.git
synced 2026-03-12 20:50:49 +08:00
fix number formats
This commit is contained in:
@@ -49,7 +49,7 @@ extension FileFormatter on num {
|
||||
final base = base1024 ? 1024 : 1000;
|
||||
if (this <= 0) return "0";
|
||||
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]}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user