private static string FormatUnitBase10(decimal formattedSize, string unit, PrintFormat format)
        {
            if (formattedSize != 1.0M)
            {
                unit += "s";
            }

            if (format == PrintFormat.Smart || format == PrintFormat.Abbreviated)
            {
                return(unit[0] + "B");
            }
            else if (format == PrintFormat.Full)
            {
                return(unit);
            }
            else if (format == PrintFormat.FullLowerCase)
            {
                return(unit.ToLower());
            }
            else if (format == PrintFormat.AbbreviatedLowerCase)
            {
                return(Char.ToLower(unit[0]) + "b");
            }

            throw new ArgumentException();
        }
        static private string PrintBytes(ulong size, PrintFormat format)
        {
            switch (format)
            {
            case PrintFormat.Abbreviated: return($"{size} B");

            case PrintFormat.AbbreviatedLowerCase: return($"{size} b");

            case PrintFormat.Full: return(size == 1 ? $"{size} Byte" : $"{size} Bytes");

            case PrintFormat.Smart:
            case PrintFormat.FullLowerCase:
                return(size == 1 ? $"{size} byte" : $"{size} bytes");
            }

            throw new ArgumentException();
        }
 public static string Format(ulong size, CalculationBase @base = CalculationBase.Base2, PrintFormat format = PrintFormat.Smart)
 {
     if (@base == CalculationBase.Base2)
     {
         var searchIndex = Array.BinarySearch(Base2Map, size);
         if (searchIndex < 0)
         {
             searchIndex = ~searchIndex;
             return(Base2Map[searchIndex].FormatDelegate(size, @base, format));
         }
         return(Base2Map[searchIndex + 1].FormatDelegate(size, @base, format));
     }
     else
     {
         var searchIndex = Array.BinarySearch(Base10Map, size);
         if (searchIndex < 0)
         {
             searchIndex = ~searchIndex;
             return(Base10Map[searchIndex].FormatDelegate(size, @base, format));
         }
         return(Base10Map[searchIndex + 1].FormatDelegate(size, @base, format));
     }
 }
 public static string Format(long size, CalculationBase @base = CalculationBase.Base2, PrintFormat format = PrintFormat.Smart)
 {
     return(Format((ulong)size, @base, format));
 }