Converting bytes to megabytes

前端 未结 9 539
执念已碎
执念已碎 2020-12-12 12:36

I\'ve seen three ways of doing conversion from bytes to megabytes:

  1. megabytes=bytes/1000000
  2. megabytes=bytes/1024/1024
  3. megabytes=bytes/1024/100
9条回答
  •  佛祖请我去吃肉
    2020-12-12 12:55

    In general, it's wrong to use decimal SI prefixes (e.g. kilo, mega) when referring to binary data sizes (except in casual usage). It's ambiguous and causes confusion. To be precise you can use binary prefixes (e.g. 1 mebibyte = 1 MiB = 1024 kibibytes = 2^20 bytes). When someone else uses decimal SI prefixes for binary data you need to get more information before you can know what is meant.

提交回复
热议问题