Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!purdue!decwrl!decvax!ima!mirror!frog!john From: john@frog.UUCP (John Woods) Newsgroups: comp.lang.c Subject: Re: binary data files Message-ID: <1354@frog.UUCP> Date: 2 May 89 21:56:00 GMT References: <10946@bloom-beacon.MIT.EDU> <12546@ut-emx.UUCP> <893@twwells.uucp> Organization: Misanthropes-R-Us Lines: 24 In article <893@twwells.uucp>, bill@twwells.uucp (T. William Wells) writes: > In article <89Apr30.140219edt.18480@me.utoronto.ca> zougas@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@frog.UUCP, ...!mit-eddie!jfw, jfw@eddie.mit.edu