How does a file get “corrupted” and how can I prevent it?

732 views

How does a file get “corrupted” and how can I prevent it?

In: Technology

5 Answers

Anonymous 0 Comments

As you probably know, digital files are stored as a series of bits (ones or zeros). To use a very simplified version of how files are usually structured, an image file might start off with a pattern of ones and zeros that says:

“This is an image file. This label is 500 bits long and the actual image starts at the 501th bit. The actual image is 3840000 bits long. Starting on the 501th bit, there are 8 bits telling you how red the first pixel is, then 8 bits telling you how green the first pixel is, then 8 bits telling you how blue the first pixel is, then repeat for the second pixel. The image has 400×400 pixels.”

When a program tries to open this file, it might notice “hey, the label at the start of the file says the file has a 500 bit label followed by 3840000 bits of image, so the file should be 3840500 bits long, but the file is actually 3840476 bits long. I don’t know how to interpret this. Error.”

That would be an example of file corruption.

A file’s label might also say “by the way, if you add up all the ones in this file, the total should be 365903.” If some bits in the file have been accidentally changed (e.g. due to the computer’s memory getting hit by cosmic rays, which is a real thing), then that will usually change the total number of ones, so it won’t match the total recorded in the file label, and the computer will know the file has been corrupted.

Other common ways you get a corrupted file are when the program that was creating the file got unexpectedly shut down and left the file half-written, or when the computer mistakenly thinks that the file is another type of file, sort of like if someone writes down their phone number for you but you mistakenly think they’re writing down their address: if you were a computer, you’d look at the piece of paper, see “123-555-7809” and say “this is not a valid address, must be corrupted.” The number is in fact a perfectly valid phone number, but because you have been told it’s an address, you treat it as corrupted.

You are viewing 1 out of 5 answers, click here to view all answers.