fix scaling in print_rates (for bits).
(Logical change 1.95)
This commit is contained in:
parent
d7b93e1e37
commit
abf1d0b097
|
|
@ -1,3 +1,7 @@
|
||||||
|
2004-10-19 Michal <md@lnet.pl>
|
||||||
|
|
||||||
|
* fix scaling in print_rates (for bits)
|
||||||
|
|
||||||
2004-09-28 Stephen Hemminger <shemminger@osdl.org>
|
2004-09-28 Stephen Hemminger <shemminger@osdl.org>
|
||||||
|
|
||||||
* fix build problems with arpd and pthread
|
* fix build problems with arpd and pthread
|
||||||
|
|
|
||||||
23
tc/tc_util.c
23
tc/tc_util.c
|
|
@ -183,22 +183,19 @@ void print_rate(char *buf, int len, __u32 rate)
|
||||||
extern int use_iec;
|
extern int use_iec;
|
||||||
|
|
||||||
if (use_iec) {
|
if (use_iec) {
|
||||||
if (tmp >= 1024*1023 &&
|
if (tmp >= 1000.0*1024.0*1024.0)
|
||||||
fabs(1024*1024*rint(tmp/(1024*1024)) - tmp) < 1024)
|
snprintf(buf, len, "%.0fMibit", tmp/1024.0*1024.0);
|
||||||
snprintf(buf, len, "%gMibit", rint(tmp/(1024*1024)));
|
else if (tmp >= 1000.0*1024)
|
||||||
else if (tmp >= 1024-16 && fabs(1024*rint(tmp/1024) - tmp) < 16)
|
snprintf(buf, len, "%.0fKibit", tmp/1024);
|
||||||
snprintf(buf, len, "%gKibit", rint(tmp/1024));
|
|
||||||
else
|
else
|
||||||
snprintf(buf, len, "%ubit", rate);
|
snprintf(buf, len, "%.0fbit", tmp);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (tmp >= 999999 &&
|
if (tmp >= 1000.0*1000000.0)
|
||||||
fabs(1000000.*rint(tmp/1000000.) - tmp) < 1000)
|
snprintf(buf, len, "%.0fMbit", tmp/1000000.0);
|
||||||
snprintf(buf, len, "%gMbit", rint(tmp/1000000.));
|
else if (tmp >= 1000.0 * 1000.0)
|
||||||
else if (tmp >= 990 && fabs(1000.*rint(tmp/1000.) - tmp) < 10)
|
snprintf(buf, len, "%.0fKbit", tmp/1000.0);
|
||||||
snprintf(buf, len, "%gKbit", rint(tmp/1000.));
|
|
||||||
else
|
else
|
||||||
snprintf(buf, len, "%ubit", rate);
|
snprintf(buf, len, "%.0fbit", tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue