Enhancements
This commit is contained in:
@@ -15,7 +15,7 @@ class Utility
|
||||
static String formatCurrency(double number,int places=2);
|
||||
static bool fmod(double dividend,double divisor);
|
||||
static bool fmod(double dividend, double divisor,double epsilon);
|
||||
static String bytesTransferredToString(double bytesTransferred);
|
||||
static String byteCountToString(double bytesTransferred, bool perSecond = true);
|
||||
private:
|
||||
static String pad(String theString,char padChar,int toLength);
|
||||
static String addCommas(String& theString);
|
||||
@@ -34,30 +34,35 @@ Utility::~Utility()
|
||||
}
|
||||
|
||||
inline
|
||||
String Utility::bytesTransferredToString(double bytesTransferred)
|
||||
String Utility::byteCountToString(double bytesTransferred, bool perSecond)
|
||||
{
|
||||
double roundedValue = std::round(bytesTransferred * 100.00)/100.00;
|
||||
String strBytesTransferrred;
|
||||
if(roundedValue >= 1E+15)
|
||||
{
|
||||
return Utility::formatNumber(roundedValue/1E+15,2) + "Pb/s";
|
||||
strBytesTransferrred = Utility::formatNumber(roundedValue/1E+15,2) + "Pb";
|
||||
}
|
||||
else if(roundedValue >= 1000000000000)
|
||||
{
|
||||
return Utility::formatNumber(roundedValue/1000000000000,2) + "Tb/s";
|
||||
strBytesTransferrred = Utility::formatNumber(roundedValue/1000000000000,2) + "Tb";
|
||||
}
|
||||
else if(roundedValue >= 1073741824)
|
||||
{
|
||||
return Utility::formatNumber(roundedValue/1073741824,2) + "Gbb/s";
|
||||
strBytesTransferrred = Utility::formatNumber(roundedValue/1073741824,2) + "Gb";
|
||||
}
|
||||
else if(roundedValue >= 1000000)
|
||||
{
|
||||
return Utility::formatNumber(roundedValue/1000000,2) + "Mb/s";
|
||||
strBytesTransferrred = Utility::formatNumber(roundedValue/1000000,2) + "Mb";
|
||||
}
|
||||
else if(roundedValue >= 1000)
|
||||
{
|
||||
return Utility::formatNumber(roundedValue/1000,2) + "Kb/s";
|
||||
strBytesTransferrred = Utility::formatNumber(roundedValue/1000,2) + "Kb";
|
||||
}
|
||||
return Utility::formatNumber(roundedValue,2) + "B/s";
|
||||
else strBytesTransferrred = Utility::formatNumber(roundedValue,2) + "B";
|
||||
|
||||
if(perSecond)strBytesTransferrred+="/s";
|
||||
|
||||
return strBytesTransferrred;
|
||||
}
|
||||
|
||||
inline
|
||||
|
||||
Reference in New Issue
Block a user