Path: utzoo!utgpu!watmath!iuvax!purdue!mailrus!csd4.milw.wisc.edu!zdenko From: zdenko@csd4.milw.wisc.edu (Zdenko Tomasic) Newsgroups: comp.lang.c Subject: Re: "arithmetic if":: Re: Feature for the next C version Message-ID: <3600@csd4.milw.wisc.edu> Date: 29 Jul 89 04:12:36 GMT References: <55480@tut.cis.ohio-state.edu> <1989Jul20.152935.14872@utzoo.uucp> <67@motto.UUCP> <18764@mimsy.UUCP> <1389@crdgw1.crd.ge.com> <8515@batcomputer.tn.cornell.edu> Sender: news@csd4.milw.wisc.edu Reply-To: zdenko@csd4.milw.wisc.edu (Zdenko Tomasic) Organization: University of Wisconsin-Milwaukee Lines: 27 In article <8515@batcomputer.tn.cornell.edu> davidra@tcgould.tn.cornell.edu (David Rabson) writes: >C does have a generalized "arithmetic if," if you wish, although it is > .... (switch case , gcc and sun discussion omitted) >(This is probably unnecessary, but I rarely get to exercise my >FORTRAN. Can anyone explain the error in the code?) yes > PROGRAM MAIN > INTEGER I > READ(5,200) I >200 FORMAT(I) ^ This reserves integer field of only one digit/sign. when you use signed integer, sign is taken, but the magnitude (2nd character and beyond!) is not read! So you program get by fortran conversion -0 which is equivalent to 0. You either have to increase your integer field length(say I10) and right justify your input (trailing blanks within an integer field are treated as zeros!) or much more conveninetly, use list directed read, i.e. replace the read and format statement above with just READ(5,*) I >... (the rest of message deleted) -- ___________________________________________________________________ Zdenko Tomasic, UWM, Chem. Dept., P.O. Box 413, Milwaukee, WI 53201 UUCP: uwvax!uwmcsd1!uwmcsd4!zdenko ARPA: zdenko@csd4.milw.wisc.edu