public static string FormatBandwidth(double bitsPerSecond)
{
if (bitsPerSecond >= (1000d*1000d*1000d*1000d))
return String.Format("{0:##.##} TBit/s", Math.Round(bitsPerSecond / (1000d*1000d*1000d*1000d), 1));
else if (bitsPerSecond >= (1000d*1000d*1000d))
return String.Format("{0:##.##} GBit/s", Math.Round(bitsPerSecond / (1000d*1000d*1000d), 1));
else if (bitsPerSecond >= (1000d*1000d))
return String.Format("{0:##.##} MBit/s", Math.Round(bitsPerSecond / (1000d*1000d), 1));
else if (bitsPerSecond >= 1000d)
return String.Format("{0:##.##} KBit/s", Math.Round(bitsPerSecond / 1000d, 1));
else
return bitsPerSecond.ToString() + " Bit/s";
}