Saturday 10 February 2018

hard drive - I know base 2 and base 10 , MB and MiB, but i'm not understanding the byte counts shown for a directory, by du and by windows explorer


The du command shows 43G in use. I'm not sure whether that's base 2 in the sense of 2^30 or if it's base 10, in the sense of 10^9. But anyhow -


Running this du command from cygwin, to see the size of the windows directory (done from an administrative command prompt - since it seemed to have some issues reading some directories otherwise)


user@comp ~
$ du -sh /cygdrive/c/windows
43G /cygdrive/c/windows

Windows Explorer which I understand shows it in 'base 2', (a larger unit for KB,MB,GB than base 10 KiB, MiB e.t.c.), and hence a lower quantity of that larger unit is required to give the same result.


Windows explorer shows


enter image description here


46.6GB , over 50 billion bytes. (according to windows explorer)


or


46.8GB , over 50 billion bytes. (according to windows explorer)


So, du aside.


Even if I multiply the larger figure, 46.8GB by 1.048576 then I get 49.0733568 that's not over 50 billion. So that's part A of the question, but then also, part B of the question, why is the du figure so low.



Answer



The answer to Part A of the question is that you're not multiplying by the correct number. The correction factor from "binary GB", or more correctly GiB, to bytes is not 1.048576. It's 1024 cubed. That's 1,073,741,824.


46.8 x 1024 cubed = 50,251,117,363.2 The rest of the discrepancy is due to a rounding error in the "46.8". Looks like it should really be 46.813...something.


You need another factor of 1024 for each "step" in the scale of binary prefixes. For example, to go from GiB to KiB, or from MiB to B, you'd multiply by 1024 squared, which is 1,048,576.


See the Wikipedia article on "Binary prefix", particularly the table at the bottom of this section: https://en.wikipedia.org/wiki/Binary_prefix#Adoption_by_IEC.2C_NIST_and_ISO


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...