"arithmetic if":: Re: Feature for the next C version
Tim McDaniel
mcdaniel at uicsrd.csrd.uiuc.edu
Sun Jul 30 04:18:55 AEST 1989
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 at batcomputer.tn.cornell.edu>
davidra at tcgould.tn.cornell.edu (David Rabson) writes:
>200 FORMAT(I)
In article <3600 at csd4.milw.wisc.edu> zdenko at 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 at uicsrd.csrd.uiuc.edu
/\ mcdaniel%uicsrd@{uxc.cso.uiuc.edu,uiuc.csnet}
_/ \_ {uunet,convex,pur-ee}!uiucuxc!uicsrd!mcdaniel
More information about the Comp.lang.c
mailing list