Binary Files

Binary Files

Published by: Nuru

Published date: 21 Jun 2021

Binary Files Photo

Binary Files

Binary files are the ones where data is stored on the disk in the same way as it is represented in the computer memory. The binary data stored in the files cannot be read using any of the text editors.

For example; the data 2345 takes 2 bytes of memory. The number of characters written/read is the same as the number of characters written/read on the external device. Therefore, there is a one-to-one relationship between the characters written/read into the file and those stored on external devices.

The binary files organize data into blocks containing contiguous bytes of information.

In binary file, the opening mode of a text file is appended by a character b i.e.

  • “r” is replaced by “rb”
  • “w” is replaced by “wb”
  • “a” is replaced by “ab”
  • “r+” is replaced by “r+b”
  • “w+” is replaced by “r+b”
  • “a+” is replaced by “a+b”

Differences between text files and binary files

S.N.

Text File

Binary File

1. They are in human-readable formats. They are not in a human-readable format.
2. Bits represent a character. Bits represent custom data.
3. Less prone to get corrupt as changes reflect as soon as the file is opened and can easily be undone. Can easily get corrupted, even a single bit change may corrupt the file.
4. Widely used file format and can be opened using any simple text editor. Developed especially for an application and may not be understood by other applications.
5. Mostly .txt and .rtf are used as extensions to text files. It can have any application-defined extension.