tags:

views:

1024

answers:

10

When I am displaying a file size to a user, is "34KB" or "34 KB" more correct?

+2  A: 

Are you asking if there's an accepted standard as to include a space between the number and unit of measurement? If so, I would say there's not a standard, but I would personally include the space. It's up to you.

Dolph
+24  A: 

Grammatically, "34 KB" is more correct. But then again one often needs to make do with the available space on displays and reports, and also one needs to have consistency with the general use and look-and-feel of the underlying application.

Also, technically should be kB, as the SI code for 1000 (well 1024 in the digital world...) is k, for kilo, not K. Indeed as suggested by hexium, the effective technical term for 1024 bytes is a kibi byte, abbreviated as KiB (cf NIST reference on SI units for binary multiples)

So to summarize:

  • 34 KiB   // most technically and grammatically correct (albeit awkward because underused and frankly unknown even in the IT domain)
  • 34 kB    // grammatically correct, readable, and rather common
  • 34kB     // if space matters
  • 34K       // and if it matters even more ...
mjv
+1 for "Grammatically" :-D
NawaMan
Even more technically, it should be KiB (for kilobinary units: http://physics.nist.gov/cuu/Units/binary.html)
hexium
@NawaMan You mean grammatically it should be 34 KB and technically 34 kB
metal-gear-solid
@hexium right! These kibis are so much in use I forgot about them... But yes, you are right, in places where precision count, we all ought to speak and write in terms of KiB rather than kB...
mjv
Pretty sure kibis are what I feed my cat. Or is that kibbles?
Andrew
@Jitendra, technically it should be orthographically rather than grammatically.
dangph
@dangph Well... the matter of having a space or not, speaks as much to grammatical issues than to orthographic ones.
mjv
Bah at KiB. Nobody would have this fight if it weren't for hard drive manufacturers trying to overstate the capacities of their products. A Kilobyte is 1024 bytes.
rlbond
Actually, regarding the space, I would lightly disagree with all the answers so far. In LaTeX, for papers, I would use the phystex package macros to insert `\,`, which is a thin space. The Unicode equivalent is 0x202F ( ), a NARROW NO-BREAK SPACE.The form and case of the unit described above is exactly correct.
Nicholas Wilson
@rlbond: It is the hard drive manufacturers' faults for calling a kB 1024, not for calling anything KiB. "Bah at KiB" is an entirely different issue to hard drive labelling, namely that the kilo prefix should uniformly denote multiples of 1000. Even though the hard drive manufacturers abused the kB unit, and co-incidentally did so before the SI included Ki, that is unrelated.
Nicholas Wilson
@mjv, @dangph: Spaces are more lexical or even syntactical than orthographical, and certainly not grammatical.
Nicholas Wilson
+1  A: 

Windows uses KB, OS X uses KB. While mjv is correct that kB is consistent with SI, I would propose that KB is standard in the computer world. Most unix commands (e.g. ls) don't abbreviate, which is annoyingly accurate.

Kb is often used to mean kilo-bits, not to be confused with kilo-bytes. The code Alex Martelli links to uses Kb for kilo-bytes, which is non-standard.

Kenny Winker
10.6 (Snow Leopard) switched to using KB = 1000 Bytes instead of 1024 (in finder at least). For instance on my 120GB hard drive the main partition shows up as having a maximum capacity of 119.56GB, which is about what you would expect with a file system and the separate boot partition.
envalid
Hmmm, my (non-English) copy of Windows XP actually uses `kB`. The English version I'm running in a VM does indeed use `KB`, though. (And they both put a space between the number and the unit)
mercator
Obligatory xkcd link. http://xkcd.com/394/
bryanjonker
+6  A: 

In the SI Units (Système International d'unités), the recommended format is a space between the number and the units - so as @mjv said, it is better to write '34 KB' than '34KB'.

There is also a standard for binary units:

  • KiB - Kibibytes (10241 bytes)
  • MiB - Mibibytes (10242 bytes)
  • GiB - Gibibytes (10243 bytes)
  • TiB - Tebibytes (10244 bytes)
  • PiB - Pebibytes (10245 bytes)
  • EiB - Exbibytes (10246 bytes)
  • ZiB - Zebibytes (10247 bytes)
  • YiB - Yobibytes (10248 bytes)

There are valid grounds for suggesting the 'KB' should be written 'kB' (as 'kg' is correct for kilogrammes, and 'K' stands for Kelvin - units of temperature). However, the generally used convention is 'KB'.

Jonathan Leffler
I defy anyone to say "Zebibytes" or "Yobibytes" with a straight face. Or "Mibibytes", for that matter.
Michael Myers
Pfft to Yobibytes. When are we getting an SI unit of Gigaquads?
Andy
+36  A: 

According to http://physics.nist.gov/cuu/Units/checklist.html,

15 - There is a space between the numerical value and unit symbol, even when the value is used in an adjectival sense, except in the case of superscript units for plane angle.

Make sure you use a non-breaking space, if possible, to prevent the units being on a following line from the number.

Kevin Jones
+1 for non breaking space
mouviciel
+28  A: 

Some of the previous answers seem to have reached a consensus that:

  • 1 kB = 1000 bytes
  • 1 KiB = 1024 bytes

But that doesn't answer your question: your question was whether or not to include a space between the numeric component and the unit description component.

IMHO, including the space is correct, because:

  1. Grammatically makes more sense, easier to read, etc. Because when you read 250kB or 250 kB aloud, in both cases you should naturally gravitate toward 250 kilobytes. Emphasis on the space, simply because they are indeed two separate words. (Try it!) (1)

  2. Technically, the space just makes things easier. For example if you find yourself needing to parse the number out of the string value using a regular expression or tokenizer sometime in the future, for example to estimate the number of bytes using the string value, having whitespace seperator just makes thigns that much easier.

  3. Just looks neater

Footnote: (1) Contrast this with just 250. You should naturally gravitate toward twoHundredAndFifty when reading it aloud, because we treat it as a single word (or at least I do)

bguiz
Technically, you shouldn't pronounce the "And"...
rlbond
Pedantry: `s/250 kb/250 kB/`
Jed
@rlbond: in American English that may be true, but in British English, I'd say that the "and" is required.
Steve Melnikoff
@rlbond @steve here in australia we say the "and" too
bguiz
@bguiz,Steve: Aside from regional differences, what should be the correct pronunciation grammatically, with the "and" or without the "and"? I am curious.... :)
Night Shade
@Sayem Ahmed : I would say with the "and" - but I can't say for certain that that isn't a regional thing.
bguiz
I've always said the 'and' here in America as well, but wouldn't think it wrong to leave out the 'and' either
Gordon Tucker
+4  A: 

Just remember that 'KB' (or your favorite variation of choice) is short for 'kilobyte'. In a full-blown sentence, you wouldn't write, for example, The size of this RTF file is 34kilobytes.. You would put a space there. Essentially, it's the same with the abbreviation.

Alexsander Akers
+1  A: 

In physics you normally don't include a space, for example 10m, 65km/h, etc. Since bytes are a memory unit just like meters are a length unit, I believe that space should not be included.

Seth Illgard
+1  A: 

Actually, I would lightly disagree with all the answers so far. In LaTeX, for papers, I would use the phystex package macros to insert \,, which is a thin space. The Unicode equivalent is 0x202F ( ), a NARROW NO-BREAK SPACE.

Other answerers are right that the most pedantic form of the unit itself is KiB; the non-SI form is kB without an upper-case k.

Nicholas Wilson
A: 

Just one interesting detail about this problem. In my language (Czech) putting or not putting the space between value and units makes a difference. When you use space then you mean noun, like - I have 2 GB left on my hard drive. Whereas without space it means adjective, like - I have 2GB flash drive.

But according to the Kevin Jones' answer this is not the case of english language, so consider my answer just like extra information someone may find interesting.

Matajon