views:

368

answers:

11

Im trying to convert a size, lets say 244410368 bytes to xxxxxx mebibyte (MiB) but I have no idea how.

All this 1000 and 1024 bytes/bits are rather confusing.

+4  A: 

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.

Greg Beech
+2  A: 

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

The 1,000 vs. 1,024 thing is mega/giga/terabytes to bytes, and is indeed confusing (especially when you're talking about hard drive capacities).

ceejayoz
Yeah I was after the 2nd part of your answer
Mint
A: 

Easy

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

You see, a byte is 8 bits, so multiplying it by 8 will get your answer.

ILMV
A: 

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

Now there are 8 bits in one byte..

So multiply by 8 ;)

Arcturus
A: 
bits=$((${bytes}*8))
maxwellb
A: 

There are 8 bits in a byte. If your units are raw bytes, you can just multiply by 8 to get bits. The 1024 numbers don't come into effect until you're dealing with prefixes. For example, a kilobyte is 1024 bytes. Wikipedia has a nice table.

msergeant
No one I ever talk to uses "kibibyte" to mean 1024 bytes. Or mebi, etc to mean 1024*..*1024 bytes.
maxwellb
@maxwellb Then you're probably talking to the wrong people ;)
phihag
Mebibyte may sound weird, but I think more weird is hearing "one megabyte" and not knowing how much really it is.
el.pescado
A: 

So a Megabyte is 1000 * 1000 bytes, and a Mebibyte is 1024 * 1024 bytes. So to turn 244410368 bytes to MiB divide by 1048576 (1024 * 1024). I hope that helps a bit.

Also, if you want to convert MB to MiB, multiply by 1000000 and divide by 1048576. That is the difference between them.

plor
A: 

Short story K (Kilo) in IT mean 2^10, M(Mega) is 2^20, G (Giga) is 2^30 and T (Tera) is 2^40 and so on. You can use the calculator to do this,”select scientific view, then click on Hex or Bin” type the number and then hit Dec.

Number to K divide By 2^10, K to Number multiply By 2^10

Number to M divide By 2^20, M to Number multiply By 2^20

Number to G divide By 2^30, G to Number multiply By 2^30

Number to T divide By 2^40, T to Number multiply By 2^40

Bit to Byte divide By 8, Byte to Bit multiply By 8

Waleed A.K.
+4  A: 

This should be valid for edited question:

1MiB = 1024*1024 B, so:

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

244410368 B = ~233 MiB

(please do not edit your questions in such way to change totally their meaning, this is confusing and now all previously good answers are not valid, you can close (or just leave) question and ask another one)

Lukasz Dziedzia
Good point, ill do that if something like this happens again.
Mint
+8  A: 

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.)

unutbu
+1 for showing a Unix command I didn't know yet.
Philipp
I don't have the "units" command but I do have the man page for it.... (on Debian)
Mint
@Mint: Do you have this package installed: http://packages.debian.org/lenny/units
unutbu
Huh thats strange, I done 'aptitude install units' before and it didn't work, but I added a new source from a different country and done the update and it worked... strange it seemed to still download from my local repo... oh well, all works now, thanks!
Mint
A: 

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

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

Praveen S