Re: Binary files
From: Michael Mair (Michael.Mair_at_invalid.invalid)
Date: 12/13/04
- Next message: Ulrich Eckhardt: "Re: switch expression not integral ???"
- Previous message: bayxarea-usenet_at_yahoo.com: "switch expression not integral ???"
- Maybe in reply to: KiLVaiDeN: "Re: Binary files"
- Next in thread: KiLVaiDeN: "Re: Binary files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 13 Dec 2004 22:13:26 +0100
alice wrote:
> hi all,
> Can anybody please tell the advantages which the binary files offers
> over the character files.
Sounds a little bit like a homework assignment.
I'll take the risk:
Let us assume we have a platform/implementation with bytes of
8 bits and 32 bit ints and 64 bit doubles which can be considered
IEEE doubles.
Now, if you store a very small negative integer number, say
-1000000000, you need (up to) 11 bytes whereas storing it in
binary takes only 32/8=4 bytes; similarly for doubles:
Storing a number as text (decimal fraction) takes up to 23
bytes whereas the binary takes only 8 bytes.
So, you save some (disk) space.
On the other hand, the binary representation on another
platform may be different which means that you can no longer
use the old files. Storing everything as text means that
you only have to use a standard tool for text file conversion
and can further use your old data files.
Another point: If everything is written out as text, you are
able to manually tweak the data if needed, only using a simple
text editor. Tweaking binary files usually is not much fun...
Have also a look at the comp.lang.c FAQ. It is probably best
if you download the text version and just search for "binary":
ftp://ftp.eskimo.com/u/s/scs/C-faq/faq.gz
For the HTML version start from here:
http://www.eskimo.com/~scs/C-faq/top.html
Note that this answer is not "complete"; there are of course
platform-independent "binary" files but there you do not store
objects from the memory directly to the file but convert them
to a certain format beforehand.
Cheers
Michael
-- E-Mail: Mine is an /at/ gmx /dot/ de address.
- Next message: Ulrich Eckhardt: "Re: switch expression not integral ???"
- Previous message: bayxarea-usenet_at_yahoo.com: "switch expression not integral ???"
- Maybe in reply to: KiLVaiDeN: "Re: Binary files"
- Next in thread: KiLVaiDeN: "Re: Binary files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|