KB: 1024 vs 1000

PowerShell Team

I love the fact that we designed PowerShell for Admins and IT Pros and love to demonstrate what that means.  Often I’ll demo PowerShell and show how you can use “KB”, “MB”, and “GB” as I did in my previous blog entry:

PS> 1kb
1024
PS> 1mb
1048576
PS> 1gb
1073741824
PS> 1kb+2mb+3gb
3223323648

Almost uniformly, the crowds LOVE this but every now and a again someone make the point that “kb” should be 1000 not 1024.  One of our readers (Dan) made this point in comments to the last post and even provided a pointer to a Wikipedia article to back up his position.  This is not an unreasonable position but I’ll make 3 points:

  1. No matter what you pick, some people will like the choice and others will not.
  2. In the context of Admins and IT Pros, KB really does mean 1024 not 1000.   (The reaction from my audiences is very consistent about this though they might just be being polite while privately thinking I’m an idiot 🙂 ).
  3. Being the architect of a V1 has its advantages (you get help make these decisions).

Now if your head and heart are really into 1000, don’t despair, PowerShell supports Scientific notion:

PS> 1e3
1000
PS> 6e6
6000000
PS> 1e100
1E+100 

We also support Hex format

PS> 0xFFFF
65535
PS> 0xCAB
3243

And others.  BTW – All of this is covered by Lee Holmes’s O’Reilly BookWindows PowerShell Quick Reference.  (Lee is a PowerShell developer and did a great job with this book.)  This is the sort of book that you print out and keep next to your keyboard because you are always looking up something.    On page 14, Lee shows you how you can convert to any numberbase (binary, octal, etc.)

Enjoy

Jeffrey Snover [MSFT]
Windows PowerShell/MMC Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

0 comments

Discussion is closed.

Feedback usabilla icon