0

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.

DrZoo
  • 10,469
  • 4
  • 42
  • 60
barlop
  • 23,380
  • 43
  • 145
  • 225
  • Likely related: http://superuser.com/questions/704218/why-is-there-such-a-big-difference-between-size-and-size-on-disk – Broots Waymb Aug 12 '16 at 15:26
  • @DangerZone no this http://superuser.com/questions/66825/what-is-the-difference-between-size-and-size-on-disk is not. Since as you see in my question, even if I take the size on disk which is the larger figure, and muliply that by 1.048576 then it doesn't reach the total byte count. And i'm not asking why windows explorer shows two difference sizes. I'm not asking difference between actual size and size on disk. – barlop Aug 12 '16 at 15:27
  • I said related, not a duplicate. Someone who is wondering why the sizes are not equal (like myself) might be curious as to why. Your question got me thinking is all. I was not proposing that post to be a likely solution in any way. – Broots Waymb Aug 12 '16 at 15:33
  • 1
    Have you looked at the -k option? `-k, show sizes as multiples of 1024 bytes, not 512-byte` – DrZoo Aug 12 '16 at 15:38
  • 46.8GB(the binary GB, the bigger unit of which there are less). So, how to convert it to the decimal GB, the smaller unit of which there are more). So if it was 46.8MB then that'd be *1.048576. because 46.8 times 1048576 is how many bytes. 1.048576 is related to that. MB in particular. – barlop Sep 05 '16 at 11:45

1 Answers1

2

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

Jamie Hanrahan
  • 23,140
  • 6
  • 63
  • 92