I need to convert megabytes to the appropriate unit.
parseInt(10000) * 1024 * 1024 //10485760000 byte
filesize(parseInt(10000) * 1024 * 1024); // "9.77 GB"
9.77 GB seems to be wrong. When I convert it using google converter online i get:
10485760000 Byte = 10,48576 Gigabyte
Why is this packages behavor like this?
The SI units are (mostly) based on decimal fractions, so do their prefixes:
When digital base 2 computers were developed they invented new prefixes. Agreement about values was soon reached but it wasn't easy to find catchy names. Unfortunately, the names that eventually spread where the SI ones, so we ended up with a nice confusion:
Then, someone invented some new names that were arguably not as bad as previous ones, but it was too late and almost nobody uses them:
In computers almost everything is a power of 2 so decimal-based units are usually avoided because they are never round.
In your example, using base 2 and base 10 prefixes renders this:
The value you want it probably the first one given that it's a file size.