Converting from 1000 to 1024 bytes

I'm trying to convert a size, say 244410368 bytes to megabytes xxxxxx (MB), but I have no idea how to do this.

I find the idea of ​​1000 and 1024 bytes / bit quite confusing.

+4
source share
11 answers

Although unit conversion is not terribly complicated math, reducing the number of hard-coded numbers and shell scripts may be an idea (rather than a calculation). If your linux system has a units program, you can do unit conversions as follows:

 % units --terse "244410368 bytes" "MiB" 233.08789 % units --terse "244410368 bytes" "MB" 244.41037 

(In Ubuntu, the units program is provided by the (surprise!) units package.)

+15
source

The de facto size for a byte is 8 bits, so just convert by 8 to convert the number of bytes into several bits.

+5
source

This should be true for the edited question:

1MiB = 1024 * 1024 B, therefore:

244410368 B = 244410368 / (1024 * 1024) MiB, therefore:

244410368 B = ~ 233 MiB

(please do not modify your questions in such a way as to completely change their meaning, this is confusing, and now all previously good answers are invalid, you can close (or just leave) the question and ask another question)

+4
source

1 byte - 8 bits. http://www.google.com/search?q=1+byte+in+bits

1000 versus 1024 is mega / gigabyte / terabyte in bytes, and this is really confusing (especially when you talk about hard drive capacity).

+2
source

So, megabytes are 1000 * 1000 bytes, and Mebibyte is 1024 * 1024 bytes. So, to turn 244410368 bytes into the MiB section on 1048576 (1024 * 1024). Hope this helps a bit.

In addition, if you want to convert MB to MiB, multiply it by 1000000 and divide by 1048576. This is the difference between them.

+1
source

Easy

 244,410,368 bytes * 8 = 1,955,282,944 bits 

You see that the byte is 8 bits, so multiplying it by 8 will give you the answer.

0
source

See this wiki link: http://en.wikipedia.org/wiki/Byte

Now there are 8 bits in one byte.

So, multiply by 8;)

0
source
 bits=$((${bytes}*8)) 
0
source

There are 8 bits in the byte. If your units are raw bytes, you can simply multiply by 8 to get the bit. 1024 numbers do not take effect until you deal with prefixes. For example, a kilobyte is 1024 bytes. Wikipedia has a nice table.

0
source

The story of K (Kilo) in IT means 2 ^ 10, M (Mega) - 2 ^ 20, G (Giga) - 2 ^ 30, and T (Tera) - 2 ^ 40, etc. You can use the calculator to do this: "select a scientific representation, then click" Hex or Bit ", enter the number, and then click" Dec "

The number up to K divided by 2 ^ 10, K by the number times 2 ^ 10

Divide the number in M ​​by 2 ^ 20, M by the number multiplied by 2 ^ 20

Divide the number in G by 2 ^ 30, G by the number multiplied by 2 ^ 30

The number before T divides by 2 ^ 40, T by the number times 2 ^ 40

Break a bit into bytes by 8, multiply a bit by 8 by 8

-1
source

8 bits = 1 byte 1024 bytes = 1 KB 1024 KB = 1 MB 1024 MB = 1 GB

So, 1 GB = 1024 * 1024 * 1024 * 8 bits.

-1
source

Source: https://habr.com/ru/post/1314081/


All Articles