您使用“kibibyte”吗? 作为程序中的测量单位?
几十年来,在计算领域(磁盘制造商除外),1 KB(千字节)被理解为 1024 字节。 过去几年,出现了一种用 KiB(“kibibyte”)来表示 1024 字节的运动,并且将 kilobyte 的含义改为 1000 字节,这注定了我们还会有很多年的困惑。 另一方面,这场运动似乎仅限于 Gnome,以及一些过度热心的维基百科编辑。
您会将程序转换为使用 KiB 吗?如果您曾经以 KB 为单位显示文件大小,您会除以 1000 还是 1024?
For decades, in the field of computing (except disk manufacturers), a KB (kilobyte) was understood to mean 1024 bytes. In the past few years, there has been a movement to use KiB ("kibibyte") to mean 1024 bytes, and change the meaning of kilobyte to be 1000 bytes, dooming us to many more years of confusion. On the other hand, the movement seems to be confined to Gnome, and some overzealous wikipedia editing.
Will you be converting your programs to use KiB? If you have ever displayed a filesize in KB, did you divide by 1000 or 1024?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(23)
KB 是 1024 字节,该死。
KB is 1024 bytes, damnit.
我之前在一个应用程序中做过一次。 虽然它在内部使用 kibbi's 和 mebbi's(KiB、MiB 等),但它仍然会以用户(在本例中为 IT 人员)习惯的方式显示。 底层字段只是一个以字节 IIRC 为单位的 long。
它向前兼容,至少允许您输入 4 GB 和 4GiB。 它还理解 4.5G 等速记输入,并正确舍入到实际字节数 - 不会强迫可怜的用户必须以这种方式输入并防止他们出错。 更新为使用 IEC 符号只需 1 行代码。
公斤是 1000,世界上 98% 的人使用公制。 我们已经需要克服它了。
我在许多这些反应中看到了很多愤怒,这让我感到困惑。 SI 前缀就是 SI 前缀,程序员无权出于方便和自定义的原因而更改它们。 奇怪的是,计算机科学这个技术含量很高的领域,却吵着要回到肘弗隆和棒的时代。 哇?
我们都知道我们的意思,但坚持自定义会疏远用户并使用户感到困惑。 仅仅因为在早期先驱时代,一些人在谈论计算机内存时决定重用 SI 表示法,并不意味着他们这样做是正确的。
I did this once before in an app. While internally it used kibbi's and mebbi's (KiB, MiB, etc), it would still display in what users (in this case IT folks) were used to. The underlying field was just a long that was in bytes IIRC.
It was forward compatible, and would at least allow you to enter 4 GB as well as 4GiB. It also understood shorthand entry like 4.5G and properly rounded back to the real number of bytes - not forcing poor user to have to enter it that way and prevent their mistakes. Updating to use IEC notation is 1 line of code.
kilo's are 1000 and 98% of the world uses metric. We need to get over it already.
I see a lot of anger in many of these responses which baffles me. SI prefixes are SI prefixes, and programmers have no right to alter them for no better reason than convenience and custom. It's odd that those in Computer Science, a highly technical field, are the one's clamoring to go back to the days of cubits furlongs and rods. wtf?
We all know what we mean, but sticking to custom alienates and confuses users. Just because in the early pioneer days some guys, when talking about computer memory, decided to reuse SI notation doesn't mean they were correct to do so.
在我看来,1 KB 等于 1000 字节是驱动器制造商希望您相信的说法,这样您的驱动器看起来比实际情况更宽敞。 ;)
In my opinion, 1 Kilobyte equals to 1000 bytes is something drivemakers want you to believe, so that your drive looks more spacious than it really is. ;)
由于我在转专业之前花了几年时间学习成为一名机械工程师,所以我不得不承认“公斤”对我来说总是意味着 10^3。 从这个角度来看,KiB 是有道理的。 然而,试着大声说几次“kibibyte”,想想你听起来有多蠢。
因此,千克为 1000 克,千字节为 1024 字节。
附录:此外,我同意那些人的说法,即如果已经建立的有效的话,我们就不应该改变它。 1024 只是一个更好的二进制数字。 另外,“kibibyte”听起来仍然像狗吃的东西。
Since I spent a few years learning to be a mechanical engineer before switching majors, I have to admit that "kilo" always means 10^3 to me. From that standpoint, KiB makes sense. However, try saying "kibibyte" outloud a few times, and think about how dumb you sound.
Therefore, kilogram is 1000 grams, kilobyte is 1024 bytes.
Addendum: In addition, I agree with those who have been saying that we shouldn't change what is already established if it works. 1024 is simply a nicer number in binary. Also, "kibibyte" still sounds like something a dog eats.
它并没有改变“千字节”的含义。 Kilo 的意思是 1000。有些人错误地使用它来指代 1024 字节的单位。
我从不以千字节为单位显示文件大小,因为用户不关心 1000 与 1024。相反,我总是使用“XXX KB/MB/GB”,其中 XXX 是字节数除以 1000/100 万等。
It's not changing the meaning of "kilobyte". Kilo means 1000. Some people were using it incorrectly to refer to units of 1024 bytes.
I never display file sizes in kibibytes, because users don't care about 1000 vs 1024. Instead, I always use "XXX KB/MB/GB", where XXX is the number of bytes divided by 1 thousand / 1 million / etc.
有两种方法可以考虑这个问题:
使用您正在运行的操作系统所使用的内容。 这样用户就可以获得一致的体验。
使用正确的东西。
如果你总是使用 KiB,就不会有混乱。 如果您使用 KB 则会出现混乱。 因此,如果您选择选项#2,那么您最好实际使用 1024 并使用 KiB 后缀。 无论如何,使用 2 的幂更有效。
这取决于你,但我的经验法则是,如果你有技术受众,那么使用 KiB 并避免所有混乱。 如果您拥有大量非技术用户,请使用您的操作系统所使用的内容。 顺便说一句,Windows 使用 KB 来表示 1024 字节。
There are 2 ways to think about this:
Use what the operating system you're running on uses. That way users have a consistent experience.
Use what is correct.
If you use KiB always though there will be no confusion. If you use KB there will be confusion. So if you chose option #2 then you're better off actually using 1024 and using the KiB suffix. Working with powers of 2 is more efficient anyway.
It's up to you but my rule of thumb would be that if you have a technical audience, then use KiB and avoid all confusion. If you have a large user base of non technical users, then use what your operating system uses. By the way Windows uses KB to mean 1024 bytes.
专业领域总是以该专业可以理解的方式使用术语。 例如,一位建造桥梁的机械工程师使用“压力”一词来表示与一位律师发现他的明星证人在法庭第一天撒谎时完全不同的含义。 我们是否应该仅仅因为该定义被更广泛地使用就要求工程师使用与律师相同的“压力”定义? 如果我们这样做,我就不会开车过那座桥!
千字节 = 1024 字节。 这是一个行业公认的专业化术语。
Areas of speciality have always used terms in ways that are understood by that specialisation. For example, a mechanical engineer building a bridge uses the term "stress" to mean something completely different from, say, a lawyer who finds out his star witness has been lying on the first day in court. Should we mandate that the engineer use the same definition for "stress" as the lawyer just because that definition is more widely used? If we do, I'm not driving across that bridge!
Kilobytes = 1024 bytes. Its an industry accepted specialisation of the term.
我用的是KiB。
你真的想拒绝使用像 IE 这样完善的标准来伤害所有人吗?
I use KiB.
Do you really want to hurt everyone by refusing to use well-established standards just like IE?
我始终以 1000 字节千字节为单位显示文件大小。 对于那些无法区分差异的人来说,这几乎不重要,并且当他们看到实际数字时往往会缓解困惑。 65323 字节 = 65Kb 四舍五入后,“正常”人就是这样。
我可能永远不会显示“KiB”,因为这从来都不是我的客户想要的。
决定不遵循不仅仅是计算机社区创建的标准(看……Kilo 实际上意味着 1000 并不“新”)的傲慢令人震惊。
I've always displayed file size in 1000-byte Kilobytes. It hardly ever matters to the people who can't tell the difference, and often relieves confusion when they see the actual number. 65323 bytes = 65Kb when rounded, and the "normal" people like that.
I probably won't ever display "KiB", since that's never what my customers want.
The arrogance of deciding not to follow the standard created by more than just the computer community (see... it isn't "new" that Kilo actually means 1000) is staggering.
仅当情况需要时才这样做。 几乎在所有情况下,基于 1,000 的单位更为合适。
据我所知,唯一的例外是内存(因为它自然是以 2 的幂的倍数表示)和 CD 大小(因为制造商以 220 字节的倍数来衡量)。 其他一切,包括硬盘驱动器、DVD、闪存驱动器、带宽、处理器速度、内存总线等,目前的测量单位都是 1000 秒,文件大小也应该是 1000 秒。 (或者,至少,我和Steve Jobs 认为 Windows 可能会继续以 1024 秒为单位测量文件大小...)
为了避免混淆用户,请使用 k- = 1,000 和 Ki- = 1,024。
草率地使用“k”来表示 1024 是一种邪恶的行为,应该用火杀死。
Only if the situation called for it. In almost all cases, 1,000-based units are more appropriate.
The only exceptions I know of are memory, since it naturally comes in multiples of a power of two, and CD size, since it's measured in multiples of 220 bytes by the manufacturers. Everything else, including hard drives, DVDs, flash drives, bandwidths, processor speeds, memory buses, etc. is currently measured in 1000s, and file sizes should be, too. (Or, at least, me and Steve Jobs think so. Windows will probably continue measuring file sizes in 1024s for years...)
To avoid confusing the user, use k- = 1,000, and Ki- = 1,024.
The sloppy usage of "k" to mean 1024 is an unholy abomination that should be killed with fire.
Mac OS X 不使用 KiB、MiB、GiB。 另一方面,当它使用公制时,它至少可以正确地进行数学计算:
就我个人而言更愿意把这些东西弄好,以便当前一无所知的用户可以从中学习。 等待用户先改变是愚蠢的。 用户不会有一天突然醒来并认为 1 KB 是 1024 字节 - 是软件让他们这样想的,所以纠正错误不应该是软件的工作吗?
Mac OS X doesn't use KiB, MiB, GiB. On the other hand, when it uses the metric ones, it at least does the maths correctly:
Personally I prefer to get this stuff right so that users who are currently in the dark would learn from it. Waiting for users to change first is just foolish. Users didn't suddenly wake up some day and think that a kilobyte is 1024 bytes - it was software which made them think that, so shouldn't it be software's job to correct the mistake?
我在存储行业工作了十年。 关于 TB 大小的争论可能会使解决方案的大小发生 10% 的变化。 简而言之:程序员和存储行业使用不同的测量方法。 两者都不总是正确的。
存储网络行业协会 (SNIA) 词典将千字节定义为:
我的经验法则是:
总的来说,这让我摆脱了麻烦。
I've worked in the storage industry for a decade. Arguments over the size of a TB can vary the size of a solution by 10%. In short: programmers and the storage industry use different measurements. Neither are right all the time.
The Storage Networking Industry Association (SNIA) dictionary defines kilobyte as:
My rule of thumb is:
By and large, that keeps me out of trouble.
我正在开发的一个程序默认使用“KiB”,但用户偏好使用哪种测量单位(1024 B 以 KiB 为单位,1024 B 以 KB 为单位,或 1000 B 以 KB 为单位)。
One program I'm working on uses "KiB" by default, but has a user pereference as to which unit of measurement to use (1024 B in a KiB, 1024 B in a KB, or 1000 B in a KB).
1024 字节就是千字节,无论这是否有意义。
过去使用“kilo-”前缀表示 1024 字节的单位可能是一个错误。 但现在它已成为标准。 现在尝试改变它只会增加混乱。
我们没有按照世界应有的方式对待世界; 我们按现状对待世界。
No. 1024 bytes is a kilobyte, regardless of whether that makes sense.
The usage of the "kilo-" prefix for units of 1024 bytes back in the day was probably a mistake. But it's now the standard. Trying to change it now only adds to the confusion.
We don't deal with the world as it should be; we deal with the world as it is.
从技术上讲,KiB 是正确的,但我只在少数应用程序(主要是 Linux 控制台应用程序)中看到它。 用户要么习惯于 KB 和 KiB(IT 人员)使用 1024,要么他们并不真正关心并会认为“KiB”拼写错误(非 IT 人员)。
然而:我已经习惯使用“千字节 = 1024 字节”20 多年了,即使我知道它在科学上是错误的,我也会继续使用它。
如果您需要提供 KiB 让您的灵魂休息,请将其作为一个选项提供,但不要将贫穷的用户与另一个定义混淆 - 特别是如果他们使用使用非科学方法并定义 KB 的操作系统为 1024。
(顺便说一句:Kibibytes 总是让我想起 Tinky Winky 和他的 朋友... ;) )
Technically KiB is correct, but I have seen it only in a few applications (mainly linux console apps). Users are either used to work with 1024 for both KB and KiB (IT people) or they don't really care and will think that "KiB" is misspelled (non-IT people).
However: I have been used to work with "Kilobytes = 1024 bytes" for over 20 years now and even though I know that it is scientifically wrong will go on using it.
If you need to provide KiB to allow your soul to rest, make it available as an option, but don't confuse poor users with yet another definition - especially if they work with an OS, that uses the non-scientific approach and defines KB as 1024.
(BTW: Kibibytes always reminds me of Tinky Winky and his friends... ;) )
我在教学生时尝试开始使用这些术语,但现在我已经放弃了。
我曾多次教授过计算机入门课程(“这个是一个磁盘驱动器”),对于学生来说,前缀含义不同可能会感到困惑在不同的背景下。 当您有千字节或千比特数据时,Kilo 表示 1024,除非您将其存储在磁盘上,此时数据为 1000,如果您通过网络每秒发送 1 千比特,那么它就是 1000,千赫兹当然也是 1000 。 而一公里的光缆就是1000米! 但事实证明,这确实不是什么大问题。 工程和计算机科学的学生需要知道其中的区别,而且无论如何他们都会习惯的。 当我在数据库课程或编译器课程中再次遇到它们时,我对不同种类的千、兆和兆从来没有任何混淆。 来自其他领域(媒体设计等)的学生并不真正关心。
在我对大学走廊里的其他计算机科学人员进行了一次非正式民意调查后,发现他们中的大多数人从未听说过这些新前缀,我果断放弃了。
I tried to start using these terms when teaching my students, but I've sort of given up now.
I've taught an introductory computer course ("and this is a disk drive") a few times, and it can be confusing for the students that the prefixes mean different things in different contexts. Kilo means 1024 when you have a kilobyte or a kilobit of data, except if you store it on disk when it is 1000, and if you send a kilobit per second over a network then it is 1000, and a kilohertz is of course 1000 too. And one kilometer of fiber cable is 1000 meters! But it turns out that it really isn't that much of a problem. The engineering and computer science students need to know the difference, and they will get used to it anyway. When I meet them again in database courses or in the compiler course, there is never any confusion about the different kinds of kilos, megas and teras. And students from other areas (media design and so on) don't really care.
And after I did an informal poll among the other computer science people in my corridor at the university, and found out that most of them had never heard of these new prefixes, I definitely gave up.
1 KB 为 1024 字节
1 kB 等于 1000 字节
不幸的是,拼写是含糊不清的。 我总是使用 1024。Knuth
将 MB 称为 KKBytes 或 kkBytes 来区分 1024*1024 和 1000*1000
A KB is 1024 bytes
A kB is 1000 bytes
unfortunately spelled out is ambiguous. I always use 1024.
Knuth refers to MB as KKBytes or kkBytes to differentiate between 1024*1024 and 1000*1000
我仍然采用 210*n 的测量值,直到计算机基于十进制...
I'm still going by measurements of 210*n until computers are based on decimal...
当您使用十进制数字系统时,基洛意味着 10^3。
当您使用二进制数字系统时,Kilo 表示 2^10。
我的意思是,看看吧……他们都很随意。 在我看来,其他任何事情都同样是任意的——所以我们有 40 年根深蒂固的任意与全新的任意。 哪个应该获胜? 目前,我投票支持根深蒂固的方法,只是因为它会引起更少的混乱。
在某些时候,我们的技术必然会发生变化——想想量子/基因计算机——那将是清理我们的测量系统的好机会。
此外,一些用户总是会感到困惑——我们是否应该冒着让这一切发生的社区(我们和硬件人员)感到困惑的风险来消除他们的困惑? 我想不是。
Kilo means 10^3 when you're working in the decimal number system.
Kilo means 2^10 when you're working in the binary number system.
I mean, just look at it... they're both quite arbitrary. It seems to me that anything else is equally arbitrary - so we have 40-year entrenched arbitrary versus brand-new arbitrary. Which should win? For now, I vote for the entrenched method, simply because it will cause less total confusion.
At some point our technology is bound to change - think quantum/genetic computers - that point will be a good opportunity to sanitize our measuring system.
Also, some users will always be confused - should we remove confusion for them at the risk of confusing the community that makes it all happen (us and the hardware guys)? I think not.
对我来说,这有点像我们过去的“黑客”争论。
根据您的年龄和固执程度,“黑客”对您来说可能有不同的含义。 有一段时间,在媒体上(也许今天仍然是部分),人们认为黑客行为是非法侵入机器的行为。 但现在在行业里,给人的感觉就是一个喜欢鼓捣的人。
有一段时间,安全社区不确定这是否会成功,我们实际上尝试使用“cracker”来指代坏人。 我认为破解者并没有像我们希望的那样真正起飞,但我们已经将“黑客”重新定义为一个合法的术语,并取得了相当程度的成功。
所以对我来说这是一样的:仅仅因为媒体试图将 KB 视为
1,000
,我永远不会退缩,并且始终坚持剩余 24 位的权利。24bFL
For me, this is a bit like the 'hacker' arguments we had, back in the day.
Depending on how old and stubborn you are, 'hacker' may mean a different thing to you. For a while in the media (and probably still today, partly) people consider hacking to be the act of breaking into machines illegally. However, in the industry now, the feeling people get is that it is someone who enjoys tinkering with things.
For a while the security community wasn't sure if this would take off, and we actually tried to use 'cracker' to refer to the bad guys. I don't think cracker has really taken off like we'd like, but we have reclaimed 'hacker' as a legitimate term, to quite a reasonable degree of success.
So to me this is the same: just because the media has tried to consider a KB as
1,000
, I will never back down, and always stand up for the rights of the remaining 24 bits.24bFL
老实说,我从来没有听说过这个& 我怀疑它是否会在主流使用中获得很大的吸引力。 我无法想象为什么我想开始这样做。 千字节的当前定义是准确的 充足的。 我更愿意看到硬盘制造商开始使用准确的术语,而不是进一步简化的技术术语。 为什么制造商不能制造尺寸恰好为 xGB 的驱动器,或者简单地说出它们的实际尺寸?
I have honestly never heard of this & I doubt it's going to gain much traction in mainstream usage. I can't imagine why I would want to start doing this. The current definition of kilobyte is accurate & sufficient. I would much rather see hard drive manufacturers start using accurate terminology rather than further dumb-down technical terminology. Why can't manufacturers either build drives that are exactly xGB in size or simply say what they really are?
除了抱怨术语需要如何改变之外,我从未听说过使用这些表达方式。 它不会流行起来。
Other than rants about how the terminology needs to change, I have never heard those expressions used. It is not going to catch on.
Drivemaker/denary 千字节可以在地狱中燃烧。 二进制机器的二进制单位。
Drivemaker/denary Kilobytes can burn in hell. Binary units for binary machines.