1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-23 22:25:14 -04:00

Fixed: Humanized size show same values as size settings

This commit is contained in:
Mark McDowall
2014-12-15 12:16:01 -08:00
parent 83e3d7145f
commit 6d31b14d96
3 changed files with 26 additions and 4 deletions
@@ -8,11 +8,13 @@ namespace NzbDrone.Common.Extensions
public static string SizeSuffix(this Int64 value)
{
if (value < 0) { return "-" + SizeSuffix(-value); }
if (value == 0) { return "0.0 bytes"; }
const int bytesInKb = 1000;
var mag = (int)Math.Log(value, 1024);
decimal adjustedSize = (decimal)value / (1L << (mag * 10));
if (value < 0) return "-" + SizeSuffix(-value);
if (value == 0) return "0 bytes";
var mag = (int)Math.Log(value, bytesInKb);
var adjustedSize = value / (decimal)Math.Pow(bytesInKb, mag);
return string.Format("{0:n1} {1}", adjustedSize, SizeSuffixes[mag]);
}