How to correctly convert filesize in bytes into mega or gigabytes

How to correctly convert filesize in bytes into mega or gigabytes

If you want a reasonable user experience you should seriously consider sticking to the common convention. However, it your program to do with as you please, and if you ready to deal with customer questions regarding what a GiB is, or why your software reports different drive sizes than everything else they see, go for it. Keep in mind that the SI prefixes are great for technical documentation, but not necessarily designed for the end user to understand easily. Adam Davis Oct 21 10 at 14:56

1024 is actually wrong. The International Engineering Community IEC has developed a standard in 2000, which is sadly being ignored by the computer industry. This standard basically says that

The widely used 1024 bytes = 1 kilobyte should instead by called 1024 bytes = 1 Kibibyte KiB, 1024 KiB = 1 Mebibyte MiB, 1024 MiB = 1 Gibibyte GiB and so on.