Skip to content

Commit

Permalink
Improve readability of large numbers in user interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Viir committed Aug 15, 2022
1 parent b26b342 commit 55fbd91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions implement/elm-fullstack/Pine/CommandLineInterface.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
namespace Pine;
using System.Globalization;

namespace Pine;

public class CommandLineInterface
{
static public string FormatIntegerForDisplay(long integer) =>
integer.ToString("### ### ### ### ### ### ##0").Trim();
FormatIntegerForDisplay(integer, '_');

static public string FormatIntegerForDisplay(long integer, char thousandsSeparator) =>
integer.ToString("N",
new NumberFormatInfo
{
NumberGroupSizes = new[] { 3, 3, 3, 3, 3, 3 },
NumberGroupSeparator = thousandsSeparator.ToString(),
NumberDecimalDigits = 0
});
}
4 changes: 3 additions & 1 deletion implement/elm-fullstack/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,9 @@ static public IEnumerable<string> DescribeCompositionForHumans(
{
var blobs = composition.EnumerateBlobsTransitive().ToImmutableList();

yield return "a tree containing " + blobs.Count + " blobs with an aggregate size of " + blobs.Sum(blob => (long)blob.blobContent.Length) + " bytes.";
yield return
"a tree containing " + blobs.Count + " blobs with an aggregate size of " +
CommandLineInterface.FormatIntegerForDisplay(blobs.Sum(blob => (long)blob.blobContent.Length)) + " bytes.";

if (listBlobs)
yield return
Expand Down

0 comments on commit 55fbd91

Please sign in to comment.