binary data files

John Woods john at frog.UUCP
Wed May 3 07:56:00 AEST 1989


In article <893 at twwells.uucp>, bill at twwells.uucp (T. William Wells) writes:
> In article <89Apr30.140219edt.18480 at me.utoronto.ca> zougas at hammer.me.UUCP (Athanasios(Tom) Zougas) writes:
< : >1. Files take a bit longer to read in
> :                ^^^^^
< : Have you ever tried reading/writing a 1,000,000 real numbers using
> : ascii instead of binary? I changed an engineering analysis program
< : from being intolerably SSSLLLOOOWWW to exceedingly fast by using
> : binary data files instead of ascii. My boss was happy :-)
< Bet you were using scanf! It isn't so bad if you do it yourself, but
> scanf and friends are SSSLLLOOOWWW.

Furthermore, you could always use an ASCII representation like
	+.8000000000000+2
to represent 1/2 * 2^2 (or the value 2).  If you are going between machines
with "similar" floating point representations (binary fraction, binary
exponent), then the details of the conversion are fairly simple (especially
if you were thoughtful enough to use a header which specified the format
of the original internal representation).  If your target is something
really peculiar (a decimal computer, say) then it's no worse than converting
"2.000000000E+000", anyway.  A computer with a base-16 floating point format
could handle the binary format with shifts.
-- 
John Woods, Charles River Data Systems, Framingham MA, (508) 626-1101
...!decvax!frog!john, john at frog.UUCP, ...!mit-eddie!jfw, jfw at eddie.mit.edu



More information about the Comp.lang.c mailing list