----- Original Message -----
From: "Catherine Moroney" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Wednesday, March 01, 2000 7:01 PM
Subject: signed vs. unsigned ints in Ftn90
> This is a very elementary question I know, but I just realized that it's
> something that I really should understand.
>
> How does Fortran handle signed vs. unsigned integers, given that there's
> only a single integer datatype?
There is no specific standard support for unsigned data types.
If you assign a value > 127 to an
> integer*1 variable, does Fortran then assume that it's going to be an
> unsigned int and treat it accordingly?
The only standard Fortran data type which normally occupies 1 byte is
CHARACTER. There is no specific support for storing numeric values in
CHARACTER beyond what is implied by the intrinsic conversions to INTEGER
such as ICHAR().
And, if you assign a negative number,
> does the compiler then figure out to treat it as a signed int?
>
> And, is the following behaviour a compiler bug?
Since INTEGER*1, INTEGER*2, INTEGER*4 are extensions to the standard,
variations between individual vendors are to be expected. If INTEGER*4 is
to behave the same as default INTEGER, it must roll over to negative values
when the maximum positive value is exceeded. You could check whether there
is more than one size of INTEGER represented by standard Fortran syntax, but
the *1 *2 notation is not standard.
> Catherine
>
>
>
>
>
> --
> ------------------------------------------------------------------
> Catherine Moroney ph: (520) 626-5123
> Institute of Atmospheric Physics fax: (520) 621-6833
> University of Arizona [log in to unmask]
> P.O. Box 210081, Room 542
> (1118 East 4th Street)
> Tucson, AZ 85721-0081
>
>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|