I am trying to convert a size, let's say 244410368 bytes to xxxxxx megabytes (MB) but I have no idea how to do this.
I find the idea of 1000 and 1024 bytes/bits rather confusing.
Although unit conversion isn't terribly complicated math, reducing the number of hard-coded numbers and shell-scripting the idea (rather than the computation) may be desireable. If your linux system has the units
program, you can do unit conversions like this:
% units --terse "244410368 bytes" "MiB"
233.08789
% units --terse "244410368 bytes" "MB"
244.41037
(On Ubuntu, the units
program is provided by the (surprise!) units
package.)
The de-facto size for a byte is 8 bits, so to convert a number of bytes into a number of bits, just multiply by 8.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With