Converting bytes to megabytes

前端 未结 9 531
执念已碎
执念已碎 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 13:01

    BTW: Hard drive manufacturers don't count as authorities on this one!

    Oh, yes they do (and the definition they assume from the S.I. is the correct one). On a related issue, see this post on CodingHorror.

    0 讨论(0)
  • 2020-12-12 13:04

    Here is what the standard (SI) says:

    http://physics.nist.gov/Pubs/SP330/sp330.pdf#page=34

    0 讨论(0)
  • 2020-12-12 13:07

    Divide by 2 to the power of 20, (1024*1024) bytes = 1 megabyte

    1024*1024 = 1,048,576   
    2^20 = 1,048,576
    1,048,576/1,048,576 = 1  
    

    It is the same thing.

    0 讨论(0)
提交回复
热议问题