Add toStringRounded

This commit is contained in:
atef 2023-06-23 10:40:11 +02:00
parent a2d9017326
commit b5f025dc69
2 changed files with 3 additions and 2 deletions

View File

@ -14,7 +14,7 @@ public static class Flow
public static TextBlock Horizontal(Unit amount, Int32 width = 10)
{
var label = amount.ToString();
var label = amount.ToStringRounded();
var arrowChar = amount.Value < 0 ? LeftArrowChar : RightArrowChar;
var arrow = Enumerable.Repeat(arrowChar, width).Join();
@ -26,7 +26,7 @@ public static class Flow
[SuppressMessage("ReSharper", "CoVariantArrayConversion")]
public static TextBlock Vertical(Unit amount, Int32 height = 4)
{
var label = amount.ToString();
var label = amount.ToStringRounded();
var arrowChar = amount.Value < 0 ? UpArrowChar : DownArrowChar;
var halfArrow = Enumerable.Repeat(arrowChar, height/2);

View File

@ -8,4 +8,5 @@ public abstract class Unit
public Double Value { get; }
public override String ToString() => $"{Value} {Symbol}";
public String ToStringRounded() => $"{Math.Round(Value,3)} {Symbol}";
}