StringForRate: change the threshold for unit change.
We would show "1Mbps" for 1.0 to 1.9 actual speed, which made this not so helpful. Instead, switch to Mbps when reaching 10000 Kbps. So we show "1000 Kbps" or 1900Kbps" in the mentionned situation, and up to "9999 Kbps" (note this is still only 4 digits, so it stays readable). We then switch to "10 Mbps", which is still only withing 12% of the actual speed (but better than the previous error of up to 50%). Fixes #11821. Also use uppercase for the SI prefixes as it should be, and use %d instead of %f for the bps rating as it is an integer.
This commit is contained in:
parent
e661df2980
commit
eca5549602
@ -23,34 +23,34 @@ const char*
|
|||||||
string_for_rate(double rate, char* string, size_t stringSize, double base)
|
string_for_rate(double rate, char* string, size_t stringSize, double base)
|
||||||
{
|
{
|
||||||
double kbps = rate / base;
|
double kbps = rate / base;
|
||||||
if (kbps < 1.0) {
|
if (kbps < 10.0) {
|
||||||
const char* trKey = B_TRANSLATE_MARK("%.0f bps");
|
const char* trKey = B_TRANSLATE_MARK("%d bps");
|
||||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||||
B_TRANSLATION_CONTEXT), (int)rate);
|
B_TRANSLATION_CONTEXT), (int)rate);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
double mbps = kbps / base;
|
double mbps = kbps / base;
|
||||||
if (mbps < 1.0) {
|
if (mbps < 10.0) {
|
||||||
const char* trKey = B_TRANSLATE_MARK("%.0f kbps");
|
const char* trKey = B_TRANSLATE_MARK("%.0f Kbps");
|
||||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||||
B_TRANSLATION_CONTEXT), kbps);
|
B_TRANSLATION_CONTEXT), kbps);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
double gbps = mbps / base;
|
double gbps = mbps / base;
|
||||||
if (gbps < 1.0) {
|
if (gbps < 10.0) {
|
||||||
const char* trKey = B_TRANSLATE_MARK("%.0f mbps");
|
const char* trKey = B_TRANSLATE_MARK("%.0f Mbps");
|
||||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||||
B_TRANSLATION_CONTEXT), mbps);
|
B_TRANSLATION_CONTEXT), mbps);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
double tbps = gbps / base;
|
double tbps = gbps / base;
|
||||||
if (tbps < 1.0) {
|
if (tbps < 10.0) {
|
||||||
const char* trKey = B_TRANSLATE_MARK("%.0f gbps");
|
const char* trKey = B_TRANSLATE_MARK("%.0f Gbps");
|
||||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||||
B_TRANSLATION_CONTEXT), gbps);
|
B_TRANSLATION_CONTEXT), gbps);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
const char* trKey = B_TRANSLATE_MARK("%.0f tbps");
|
const char* trKey = B_TRANSLATE_MARK("%.0f Tbps");
|
||||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
||||||
B_TRANSLATION_CONTEXT), tbps);
|
B_TRANSLATION_CONTEXT), tbps);
|
||||||
return string;
|
return string;
|
||||||
|
Loading…
Reference in New Issue
Block a user