File compression also makes it possible to fit large collections of files onto one floppy disk. File compression works on a combination of a few basic principles such as tokenizing, elimination of repetition, and pattern identification combined with some very clever mathematics.
Lossless compression is used on program and datafiles.
This ensures that the files you get out of the archive are identical to the originals. Lossy compression can give much higher compression ratios, but you cannot guarantee that the decompressed file will match the original. For programs and data, this could be disastrous. Thus, lossy compression is used for image and audio files, where a few missed bits will not be important. For example, JPEG files use a lossy compression.