Implicit decimal points in floating-point reads
Lee E. Brotzman
brotzman at nssdcb.gsfc.nasa.gov
Fri May 24 15:43:45 AEST 1991
In article <16222 at smoke.brl.mil>, gwyn at smoke.brl.mil (Doug Gwyn) writes...
>In article <5366 at dftsrv.gsfc.nasa.gov> brotzman at nssdca.gsfc.nasa.gov writes:
>> My question: is it possible to read data that are formatted with implicit
>>decimal points in ANSI standard C without writing my own routine?
>
>No, there is no Fortranish support for that in *scanf() formats.
>
>> I'd be surprised that such an obviously useful bit of functionality
>>that has existed for decades in FORTRAN isn't available in C, ...
>
>What is obvious to ME is that such a format is an accident waiting to strike!
>
>It is also TRIVIAL to multiple a scanned integer by a power of 10 to scale
>it thusly.
Doug's response has been typical of the half-dozen or so I have
received (thanks everybody), except that it's a bit more snippish than
most.
This "accident waiting to happen" stuff is bunk however. We've
been reading data formatted with implicit decimal points quite nicely
for a few decades now, thank you very much. Haven't noticed any
problem with it until I tried using C, which simply wasn't designed
with analysis of large volumes of data in mind like Fortran was. No flame
there, just statement of opinion.
In my application, I can not know beforehand whether a specific field
has implicit decimal points, the Fortran formats don't say, they just have
the pleasant side effect of reading them correctly either way.
Inspecting the fields, converting the values and dividing by some
power of ten (which must also be selected by a string inspection) is
trivial, but perhaps not all that efficient. I'm going to be using
this code to filter records from files with 250,000 records 200 bytes
long on CD-ROM. If the CD-ROM drives can't stream the data out at
full speed, they lose their place and have to reacquire, which can
increase search times by factors of 3 or 4, so fast conversion of
field values is critical.
Sometimes -- no, make that most times -- dealing with data is not nearly
as easy as dealing with code. Programmers tend to forget this. Data
processing professionals can't afford to.
Thanks to everyone who responded publicly and privately. No
further comments are required, as I don't ordinarily read this
newsgroup.
So long,
-- Lee E. Brotzman Internet: brotzman at nssdca.gsfc.nasa.gov
-- ST Systems Corp. SPAN: NSSDCA::BROTZMAN
-- Astrophysics Data System BITNET: ZMLEB at SCFVM
-- National Space Science Data Center "Prayer: the last refuge of a scoundrel"
-- "My thoughts are my own" Lisa Simpson, 1990
More information about the Comp.lang.c
mailing list