[1] [ http://encyclopedia.thefreedictionary.com/SI prefix ]
Computing
k and greater are common in computing, where they are applied to information
and storage units like the bit and the byte.
Since 2^10 = 1024, and 10^3 = 1000, this led to the SI prefix letters being
used approximately (and wrongly) to denote "binary" prefixes as follows:
K = 2^10 = 1,024
M = 2^20 = 1,048,576
G = 2^30 = 1,073,741,824
T = 2^40 = 1,099,511,627,776
P = 2^50 = 1,125,899,906,842,624.
However, these prefixes usually retain their powers-of-1000 meanings
when used to describe rates of data communication (bit rates):
10 Mb/s Ethernet runs at 10,000,000 b/s, not 10,485,760 b/s.
[2] [ http://encyclopedia.thefreedictionary.com/bit rate ]
1000 b/s = 1 kb/s (one kilobit or one thousand bits per second)
1000 kb/s = 1 Mb/s (one megabit or one million bits per second)
1000 Mb/s = 1 Gb/s (one gigabit or one billion bits per second)
[3] [ http://encyclopedia.thefreedictionary.com/Binary prefixes ]
New IEC Standard Prefixes
Name Abbr Factor
======================
kibi Ki 2^10 = 1024
mebi Mi 2^20 = 1 048 576
gibi Gi 2^30 = 1 073 741 824
tebi Ti 2^40 = 1 099 511 627 776
pebi Pi 2^50 = 1 125 899 906 842 624
exbi Ei 2^60 = 1 152 921 504 606 846 97
w swietle powyzszych rozwazan (zwlaszcza [2]) mam zamiar
wyslac latke z zalacznika poprawiajaca przeliczanie zmiennej
bps (w iproute2: bytes per second) na podstawie podanego suffixa.
jakis sprzeciw?
--
If you think of MS-DOS as mono, and Windows as stereo,
then Linux is Dolby Digital and all the music is free...
diff -urN a/tc/tc_util.c b/tc/tc_util.c
--- a/tc/tc_util.c 2000-04-16 19:42:55.000000000 +0200
+++ b/tc/tc_util.c 2003-12-14 06:56:55.000000000 +0100
@@ -108,13 +108,13 @@
if (*p) {
if (strcasecmp(p, "kbps") == 0)
- bps *= 1024;
+ bps *= 1000;
else if (strcasecmp(p, "mbps") == 0)
- bps *= 1024*1024;
+ bps *= 1000*1000;
else if (strcasecmp(p, "mbit") == 0)
- bps *= 1024*1024/8;
+ bps *= 1000*1000/8;
else if (strcasecmp(p, "kbit") == 0)
- bps *= 1024/8;
+ bps *= 1000/8;
else if (strcasecmp(p, "bps") != 0)
return -1;
} else
@@ -158,10 +158,10 @@
{
double tmp = (double)rate*8;
- if (tmp >= 1024*1023 && fabs(1024*1024*rint(tmp/(1024*1024)) - tmp) < 1024)
- snprintf(buf, len, "%gMbit", rint(tmp/(1024*1024)));
- else if (tmp >= 1024-16 && fabs(1024*rint(tmp/1024) - tmp) < 16)
- snprintf(buf, len, "%gKbit", rint(tmp/1024));
+ if (tmp >= 1000*999 && fabs(1000*1000*rint(tmp/(1000*1000)) - tmp) < 1000)
+ snprintf(buf, len, "%gMbit", rint(tmp/(1000*1000)));
+ else if (tmp >= 1000-10 && fabs(1000*rint(tmp/1000) - tmp) < 10)
+ snprintf(buf, len, "%gKbit", rint(tmp/1000));
else
snprintf(buf, len, "%ubps", rate);
return 0;
_______________________________________________________
z�ota zasada - kto si� nie zna, niech si� nie wypowiada