9

When writing to a binary file, when should I use .bin vs .dat? If I'm just trying to store information not meant to be read by humans, like item description/serial number pair, does it matter which one I pick if I'm just trying to make it unreadable from a text editor?

6
  • 3
    You can write to whatever file extension you like. Even if it's a exe or doc
    – Danh
    Jan 3, 2017 at 7:18
  • Neither .bin nor .dat are standardized file formats, so you can use them as you please.
    – Lundin
    Jan 3, 2017 at 8:34
  • 2
    Probably a more descriptive extension is even better, like ".serdescpairs". It is more meaningful to you and, especially on windows, is less likely associated to some other application ("Open with..."). Jan 3, 2017 at 8:41
  • 1
    The file extension is not what makes it unreadable with a text editor, its binary contents does.
    – Jongware
    Jan 3, 2017 at 13:36
  • 1
    Did not know I could make my own extension. +1 @linuxfan Jan 3, 2017 at 22:20

5 Answers 5

7

Let me give you some brief details about these files :

.BIN File : The BIN file type is primarily associated with 'Binary File'. Binary files are used for a wide variety of content and can be associated with a great many different programs. In general, a .BIN file will look like garbage when viewed in a file editor.

.DAT File : The DAT file type is primarily associated with 'Data'. Can be just about anything: text, graphic, or general binary data. Data file in special format or ASCII.

Reference: Abhijit Banerjee answered that question on quora

5

.dat is a more frequently used suffix for binary data. It doesn't matter what extension you pick, as long as you are on Unix or Linux based systems.

2
  • 3
    it doesn't matter even on Windows, because the extension is only used by the GUI to determine which app to open that file. Inside the app it'll use other mechanisms like magic number to verify the file type
    – phuclv
    Jan 3, 2017 at 9:37
  • Just because the windows GUI (and even command line) uses extensions to choose a program, it is good to plan carefully. ".dat" is too much used everywhere. Jan 4, 2017 at 8:03
2

Sufixes can mean whatever you want them to mean... Those rules are more like guidelines than actual rules...

However, BIN seems like a short to binary, so a BIN file will likely hold data in binary form. DAT seems like a short to data, so a DAT file will contain information in whatever format the developer of the program that reads that file seems fit (ASCII, Binary, a mix of them, something else entirely)

0

On a UNIX system, there is no difference. The extensions are interchangeable.

0

If you do not put any extension, it makes it kinda hard for someone not knowing what the file's extension should be, to open the file. Additionally, with Unix or Linux, if you place a dot (period) before the file name, the file hides itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.