Converting bytes to megabytes

前端 未结 9 529
执念已碎
执念已碎 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

    Use the computation your users will most likely expect. Do your users care to know how many actual bytes are on a disk or in memory or whatever, or do they only care about usable space? The answer to that question will tell you which calculation makes the most sense.

    This isn't a precision question as much as it is a usability question. Provide the calculation that is most useful to your users.

提交回复
热议问题