且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将文件大小以字节为单位转换为人类可读的字符串

更新时间:2022-12-18 09:46:22

这取决于你是否想要使用二进制文件或者十进制约定。

It depends on whether you want to use the binary or decimal convention.

RAM,例如,总是用二进制来衡量,所以要表达1551859712,因为~1.4GiB是正确的。

RAM, for instance, is always measured in binary, so to express 1551859712 as ~1.4GiB would be correct.

另一方面,硬盘制造商喜欢使用小数,因此他们会称之为~1.6GB。

On the other hand, hard disk manufacturers like to use decimal, so they would call it ~1.6GB.

只是令人困惑,软盘使用两个系统的混合 - 它们的1MB实际上是1024000字节。

And just to be confusing, floppy disks use a mixture of the two systems - their 1MB is actually 1024000 bytes.