How do I perform MB and KB arithmetic?

Thread Starter

xEnOnn

Joined Feb 2, 2011
25
I am not sure how I should perform a division between megabytes and kilobytes.
Say I want to divide 256MB with 1KB. Apparently, the answer is 256KB.
But I don't know how I should get that. What I tried was this:
First, I convert both to a similar unit. So in this case, I convert 256MB to become 262144KB.
Then, I divide 262144KB ÷ 1KB = 262144KB. But this isn't right.
So I try another way to convert both to MB instead.
Then 1KB = (1 ÷ 1024)MB and then 256MB ÷ (1 ÷ 1024)MB = 0.25MB = 256KB. <-- Now, this is correct but how come I have to convert to MB before performing the division? Why having the both operands be in KB and then divide them gives me a different answer?

Then in another case, for 16KB divided by 16B,
when I convert both to KB, 16B=(16 ÷ 1024)KB and then have 16KB ÷ (16 ÷ 1024)KB = (1÷1024)KB = 1B
But if I convert both to B, then 16KB=16*1024=16384B. And then 16384B ÷ 16B=1024B=1KB.
Again in this case, both give me a different answers when divided with the same unit!

What's wrong?
Why doesn't KB ÷ KB give me an answer in KB?

Say for the first case, 256MB. I convert to 262144KB. When divided by 1KB, I get back 262144KB, which is wrong. Unless I assume that 262144 is in Bytes, then I can convert it to the correct answer by having 262144B ÷ 1024 = 256KB. BUT since I had KB ÷ KB, why is my answer in Bytes?
 

Papabravo

Joined Feb 24, 2006
21,159
If you knew anything about dimensional analysis you would know that dividing two quantities with the same units gives a dimensionless number.

Rich (BB code):
256KB / 1kB = 256, with no units whatsoever

also

262,144 Bytes / 1024 Bytes = 256, again with no units whatsoever
Got it??!!
 

Thread Starter

xEnOnn

Joined Feb 2, 2011
25
Why is the 262,144 in bytes and not in KB?
From 256MB, I multiply by \(2^{10}\), which is 1024, and I should convert 256MB to 262,144KB isn't it?
 

someonesdad

Joined Jul 7, 2009
1,583
You need to learn the difference between SI decimal prefixes (e.g., "k" and "M") and the IEC binary prefixes established about a decade ago. A megabyte is always 1e6 bytes; use MiB if you want to indicate mebibyte. Then there won't be any confusion.

When you're in doubt, in either system, substitute what the symbol means (e.g., 10^6 or 2^20); then the arithmetic is trivial.
 
Top