When I am displaying a file size to a user, is "34KB" or "34 KB" more correct?
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.
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 ...
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.
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'.
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.
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:
Grammatically makes more sense, easier to read, etc. Because when you read
250kB
or250 kB
aloud, in both cases you should naturally gravitate toward250 kilobytes
. Emphasis on the space, simply because they are indeed two separate words. (Try it!) (1)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.
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)
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.
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.
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.
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.