Xref: utzoo comp.lang.c:20247 comp.lang.fortran:2299 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc.cso.uiuc.edu!garcon!uicsrd.csrd.uiuc.edu!mcdaniel From: mcdaniel@uicsrd.csrd.uiuc.edu (Tim McDaniel) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: "arithmetic if":: Re: Feature for the next C version Message-ID: <1614@garcon.cso.uiuc.edu> Date: 29 Jul 89 18:18:55 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> <3600@csd4.milw.wisc.edu> Sender: news@garcon.cso.uiuc.edu Reply-To: mcdaniel@uicsrd.csrd.uiuc.edu (Tim McDaniel) Followup-To: comp.lang.fortran Organization: Center for Supercomputing R&D (Cedar), U. of Ill. Lines: 64 This article has been crossposted to comp.lang.c (the original newsgroup) and comp.lang.fortran. Please send all followups to comp.lang.fortran. In article <8515@batcomputer.tn.cornell.edu> davidra@tcgould.tn.cornell.edu (David Rabson) writes: >200 FORMAT(I) In article <3600@csd4.milw.wisc.edu> zdenko@csd4.milw.wisc.edu (Zdenko Tomasic) writes: > This reserves integer field of only one digit/sign. FORTRAN 77, and presumably FORTRAN 66, do not allow the I format descriptor to appear without a width. On Alliant computers, an I without a width is permitted as an extension, and the width is assumed to be 7 characters for one- and two-byte integers, and 12 for 4-byte integers. > 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. What if you're on a one's complement machine? On those, -0 need not be the same as 0. VAX BSD 4.3, SUN OS 3.5, and Alliant Concentrix 3.0 all treat a single "-" in an otherwise blank field as 0. However, I have found no statement in my manuals guaranteeing it, and if I were writing a FORMAT conversion library, I'd consider making it illegal as an ill-formed number. (After all, these I = - ! FORTRAN i = -; /* C, C++ */ are not legal -- why not be consistent, if the standard permits it?) > You either have to increase your integer field length (say I10) Yes. > and right justify your input (trailing blanks within an integer > field are treated as zeros!) In FORTRAN 77, you can use the BLANK= attribute on the OPEN statement to control whether trailing blanks are ignored or treated as zeroes, by BLANK='NULL' or BLANK='ZERO' The default is NULL -- by default trailing blanks are simply ignored. I don't believe FORTRAN 66 took a stand on the issue, and in its default, implementors treated trailing blanks as zeroes. Briefly, trailing blanks *may be* treated as zeroes. > much more conveninetly, use list directed read, i.e. replace the > read and format statement above with just READ(5,*) I Quite true! It is much better for interactive input. -- "Let me control a planet's oxygen supply, and I don't care who makes the laws." - GREAT CTHUHLU'S STARRY WISDOM BAND (via Roger Leroux) __ \ Tim, the Bizarre and Oddly-Dressed Enchanter \ mcdaniel@uicsrd.csrd.uiuc.edu /\ mcdaniel%uicsrd@{uxc.cso.uiuc.edu,uiuc.csnet} _/ \_ {uunet,convex,pur-ee}!uiucuxc!uicsrd!mcdaniel