Describe the bug
The string format output by Converters.ToFileSizeString is not uniform, KB, MB, GB, TB, PB are F1 but EB is F0, I think it should be a typo.
if (size < 1024)
{
return size.ToString("F0") + " bytes";
}
else if ((size >> 10) < 1024)
{
return (size / 1024F).ToString("F1") + " KB";
}
else if ((size >> 20) < 1024)
{
return ((size >> 10) / 1024F).ToString("F1") + " MB";
}
else if ((size >> 30) < 1024)
{
return ((size >> 20) / 1024F).ToString("F1") + " GB";
}
else if ((size >> 40) < 1024)
{
return ((size >> 30) / 1024F).ToString("F1") + " TB";
}
else if ((size >> 50) < 1024)
{
return ((size >> 40) / 1024F).ToString("F1") + " PB";
}
else
{
return ((size >> 50) / 1024F).ToString("F0") + " EB"; // Should be F1 ?
}
Regression
No response
Steps to reproduce
[TestMethod]
[DataRow(1024L - 1, "1023 bytes")]
[DataRow(1024L, "1.0 KB")]
[DataRow(1024L * 1024, "1.0 MB")]
[DataRow(1024L * 1024 * 1024, "1.0 GB")]
[DataRow(1024L * 1024 * 1024 * 1024, "1.0 TB")]
[DataRow(1024L * 1024 * 1024 * 1024 * 1024, "1.0 PB")]
[DataRow(1024L * 1024 * 1024 * 1024 * 1024 * 1024, "1 EB")] // NOTE !
public void Test_ToFileSizeString(long size, string expected)
{
Assert.AreEqual(expected, Converters.ToFileSizeString(size));
}
Expected behavior
[TestMethod]
[DataRow(1024L - 1, "1023 bytes")]
[DataRow(1024L, "1.0 KB")]
[DataRow(1024L * 1024, "1.0 MB")]
[DataRow(1024L * 1024 * 1024, "1.0 GB")]
[DataRow(1024L * 1024 * 1024 * 1024, "1.0 TB")]
[DataRow(1024L * 1024 * 1024 * 1024 * 1024, "1.0 PB")]
[DataRow(1024L * 1024 * 1024 * 1024 * 1024 * 1024, "1.0 EB")] // NOTE !
public void Test_ToFileSizeString(long size, string expected)
{
Assert.AreEqual(expected, Converters.ToFileSizeString(size));
}
Screenshots
No response
IDE and version
VS 2022 Preview
IDE version
No response
Nuget packages
Nuget package version(s)
N/A
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item
Describe the bug
The string format output by
Converters.ToFileSizeStringis not uniform,KB, MB, GB, TB, PBareF1butEBisF0, I think it should be a typo.Regression
No response
Steps to reproduce
Expected behavior
Screenshots
No response
IDE and version
VS 2022 Preview
IDE version
No response
Nuget packages
Nuget package version(s)
N/A
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item