Path: news.uiowa.edu!chi-news.cic.net!newsspool.doit.wisc.edu!night.primate.wisc.edu!sdd.hp.com!swrinde!gatech!newsfeed.internetmci.com!news.fibr.net!nntp.news.primenet.com!news.primenet.com!johnlb From: johnlb@primenet.com (John Bowling) Newsgroups: comp.sys.apple2.programmer Subject: Re: ORCA/C program problem Date: 24 Jan 1996 01:19:01 -0700 Organization: Primenet (602)395-1010 Lines: 41 Sender: root@primenet.com Message-ID: <4e4q1l$dnn@nnrp1.news.primenet.com> References: <4dqvlr$3oo@styx.uwa.edu.au> <4e274h$c5q@gap.cco.caltech.edu> <4e3sak$gmq@wraith.cc.uow.edu.au> <4e4khr$f2p@tuba.cit.cornell.edu> X-Posted-By: johnlb@usr2.primenet.com In article <4e4khr$f2p@tuba.cit.cornell.edu>, Jay Krell wrote: >david@wraith.cc.uow.edu.au (David E A Wilson) writes: > >>This results in an asymmetry - you cannot use the same format string to read >>and write some data types (scanf uses %f and %lf for float and double, >>printf uses %f for both and does not support %lf). > >And Lf for long double in both printf and scanf. And, per the Orca/C book, printf does NOT want a %lf, only an %f. scanf, on the other hand, REQUIRES a %lf for a double, and a %f for a float. Also for scanf, this is true with e, E, g, or G. What it doesn't say is how you enter an extended value with scanf. I quess, because extended is not an official part of ANSI C, that you cannot. strtod (), on the other hand, will convert the ASCII input to an extended. That's just one of billions of things I hate about scanf(). I would rather write 100 lines of code to replace one scanf(), and get my input right! According the "The Waite Group's Essential Guide to ANSI C", scanf() requires a %Lf (upper case L) for doubles (also e or g). The Orca/C book specifies this as %lf (lower case l), and allows E or G as operators, and specifies that e, f, g, E, and G are all identical for scanf (). We have a discrepancy as to which truely fits the ANSI standard. Are E and G allowable?within a scanf ()? Anyone want to quote a recent ANSI (or ISO) standard? My Waite Guide's book was printed in 1988, so it may be out of date. There have also been 3 (that I know of) upgrades to Orca/C since the book was printed (1989, 1991, 1992). John -- ------------------------------------------------------------------------------ John Bowling |Apple II GS can whip the pants off its little johnlb@primenet.com |brother (Mac) any time! ------------------------------------------------------------------------------