Binary

Programming, for all ages and all languages.
Post Reply
samjkd

Binary

Post by samjkd »

what is a binary file and what's the use of it?

what is a windows binary file?

does linux have a binary file?

how can i create a binary file?
AR

Re:Binary

Post by AR »

A "binary" is usally a generic name for an executable. Binary = computer/machine language.

A "windows binary" is a Portable Executable (PE) format program that runs on Windows

A "linux binary" is an Executable and Linking Format (ELF) format program that runs on linux (Linux also supports COFF and a.out)

You create a binary by compiling and linking code using a compiler or assembler (Like GCC and LD)
mystran

Re:Binary

Post by mystran »

While "binary" usually indeed refers to a program (and what AR said is correct in that sense), a "binary file" also often means basicly anything that isn't text.

If you are programming in (say) C, you might have noticed that you can open files in both "text" and "binary" mode. In Unix the difference is nil, since text and binary files work the same, but in Windows, opening a file as a text-file can affect the end-of-line conversion.

Depending on the meaning you are after, you can either create a binary file by compiling a program (in case of program binaries) or by simply writing some binary data into a file (binary datafiles).
DevL

Re:Binary

Post by DevL »

mystran wrote: While "binary" usually indeed refers to a program (and what AR said is correct in that sense), a "binary file" also often means basicly anything that isn't text.
A JPEG image for example is an image stored in a binary format as opossed to an HTML document which is would be considered (in the Windows world, mind you) as a text file.
ark

Re:Binary

Post by ark »

In the binary vs. text sense, all files are binary...text just means you look for certain characters (or strings) that indicate the end of the line.

From a practical standpoint, Windows ends a line of text with a carriage-return and line-feed pair. In binary mode, when you're reading the file you would see both the \r and the \n characters. In text mode, the \r\n pair is collapsed into a \n when you're reading it in (\n is similarly expanded to \r\n when writing it out). In a system like Unix where lines are terminated by a line-feed character only, there's no practical difference between the two.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Binary

Post by Solar »

Gargl...

Do you open JPEGs in a text editor? Executables? Sound files? No.

But XML, HTML, text, config-files - those you open in a text editor. (At least occassionally.)
Every good solution is obvious once you've found it.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Binary

Post by distantvoices »

Do *YOU* open text files in a mp3 player?

just take care of the *point de vue* and there is no problem with discussing it. I for one second joel. After all, a text file too keeps binary information. It just depends on who reads/interpretes the content. so *shrugs* 'n' peace.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Binary

Post by Solar »

Everything on a computer is binary. Does that make XML, HTML, C source, Perl scripts and .txt files any less of a group that is called "text files" or "plain text files", to distinguish them from what is commonly called "binary" files (JPEG, WAV, MP3, MOV, EXE, ...)?

Come on, dudes. That kind of pointification isn't helping samjkd.
Every good solution is obvious once you've found it.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Binary

Post by distantvoices »

for me, a binary is any file image. That's as it is.

The executing instance which takes the file and looks into its contents makes it be

a text file
a jpeg file
a mov file
... you get the hint.

I do not permit that global catch all definitions prevent /dev/brain from having its little grey wheels spin a bit to get the knack.

the most obvoius occurence of the meaning "binary" is when you download *hqx files with a browser in Linux (don't remember which one): it asks: "what shall i do with the file? a: filter it throu some conversion (decompressing etc) b: download it encoded c: download it as binary."
The knack is: shall the browser do some interpretation/conversion stuff to the downloaded image or shall it save the downloaded image to disk *as it is*

That's my explanation of "binary" vs "text". Now, Solar, it is your turn: better explanation? Other viewpoint?. Thanks btw for reminding me of the crucial manners of responding to the original question instead of bickering in the back. ;)
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
Post Reply