-5

Upon checking out a binary file, and according to convincing evidence, .bin file extensions are supposed to denote a file type which stores its data as 0s and 1s, or 31/32 in ASCII hex(ASCII character codes for 1 and 0). Upon entering a file I noticed that it doesn't just store 0s and 1s:

enter image description here

The first sixteen bytes fall within a possible 8-bit value (range: 0-256), which makes sense since each value is a byte. But my questioning is, since it's called "bin", why does it store values like every other file? What is the difference? The values are not 1s and 0s, but values falling anywhere between 0-256 per byte. That doesn't add up to me.

Why is it called a binary file when it stores byte-ranged values the same as any other file would? How is a bin different than a jpeg?

  • "according to convincing evidence" -- nowhere in that "evidence" is stated that "binary" data gets stored "as 0s and 1s, or 31/32 in ASCII hex". It's actually a fairly good answer to your question. – usr2564301 Dec 22 '13 at 1:21
  • Honestly, anyone can use any file extension they want that's why the proper checking of a filetype is by looking for the magic number. – majidarif Nov 6 '16 at 2:44
9

From the Wikipedia article to which you linked:

A binary file is a computer file that is not a text file; it may contain any type of data, encoded in binary form for computer storage and processing purposes.

That's what you're seeing in your screenshot above, but the hex editor you're using is displaying binary data (0s and 1s) in hexadecimal form to make it more readable.

From http://en.wikipedia.org/wiki/Hexadecimal:

the primary use of hexadecimal notation is a human-friendly representation of binary-coded values in computing and digital electronics

If you prefer, you can use a hex editor like 010 Editor which will happily show you the content of the file as 0s and 1s instead of in hexademical format (View --> Edit As --> Binary in the program's menu bar).

  • If all data is stored in binary, why is there a specific file called a .bin? Everything on the computer is in binary, so what's the purpose of a binary file? Also, I don't understand hex too well, but I do binary. – confused for real Dec 21 '13 at 19:57
  • 2
    Yes, at the lowest level, storage media does store everything in binary (even text files). File extensions (such as .bin) are primarily intended to indicate to the user the type of content in the file. I don't know what file you're looking at, but someone chose to name it .bin. The extension itself doesn't change the content of the file, and doesn't always reflect the actual content of a file. For example, you could rename a .jpg file to .bin and your graphics editor would still be able to open the file just fine as a JPEG file. – Jason Geffner Dec 21 '13 at 20:00
  • Merely to indicate to a human that the contents of a file is not something simple, such as "text". An extension .txt is a strong indicator it is perfectly alright to attempt to open a file with a text editor. For .bin it signifies the opposite. – usr2564301 Dec 21 '13 at 20:01
  • So your points are that, aside from binary numbers, a .bin file is typically not parsed/read by typical software as it would a typical file, i.e. text, .txt, video, .mp4, etc. File extension, I know, does not denote format, but it is often used to do so to make it clearly differentiated from, say, another format. A .bin file is not encoded in ASCII format for Notepad to parse and display, but its format could well be understood by Intel Celeron, so the difference is merely formatting/encoding schemes. Is that what you guys mean? – confused for real Dec 21 '13 at 20:18
  • No, for your Intel Celeron to "understand" the content of the file it would need to be assembly code, and that does not appear to be the case for the file you showed above. – Jason Geffner Dec 21 '13 at 20:45
5

It seems you're new to Hex. You can think of Hex as a compact form for binary. The following table might help you:

0 hex is 0000 binary
1 hex is 0001 binary
2 hex is 0010 binary
3 hex is 0011 binary
4 hex is 0100 binary
5 hex is 0101 binary
6 hex is 0110 binary
7 hex is 0111 binary
8 hex is 1000 binary
9 hex is 1001 binary
a hex is 1010 binary
b hex is 1011 binary
c hex is 1100 binary
d hex is 1101 binary
e hex is 1110 binary
f hex is 1111 binary
  • I am not new to binary or hexadecimal, and you didn't need to show me a table. My questioning was regarding the encoding differences between bin and other formats, and that they're all 0s and 1s, in square waves, on the circuit level. My confusion was actually the encoding differences I believe, because all files are encoded at the lowest level in binary, so I didn't understand quite the difference from a bin to a, say, jpeg using that same manner of logic. But, apparently, the difference seems to lie in encoding schemes. – confused for real Dec 21 '13 at 20:21
  • I also don't find hexademical easier than binary. Strangely, binary is what I learned first, and hexadecimal seems harder to get my head around. – confused for real Dec 21 '13 at 20:30
  • @confusedforreal: which is where this table comes in real handy. Because if you know that one nibble (4 bit) is one hex digit, that table is very very useful for understanding. – 0xC0000022L Dec 22 '13 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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