Home > Archive > Fortran > February 2005 > DATA statement and BOZ literal constant
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
DATA statement and BOZ literal constant
|
|
| Steven G. Kargl 2005-02-18, 8:57 pm |
| Suppose I have a fortran processor that supports integer(kind=1)
and integer(kind=2) where kind=1 is a signed 8-bit integer and
kind=2 is a signed 16-bit integer. Now, I have the subprogram
subroutine a
integer(kind=1) b
data b / Z'4' /
print *, b
end subroutine a
Is Z'4' interpreted as a kind=2 integer, and then
converted to a kind=1 integer on assignment to b?
The relevant passage from the standard is in section 5.2.5 and
following C567:
If a data-stmt-constant is a boz-literal-constant, the corresponding
variable shall be of type integer. The boz-literal-constant is treated
as if it were an int-literal-constant with a kind-param that specifies
the representation method with the largest decimal exponent range
supported by the processor.
--
Steve
http://troutmask.apl.washington.edu/~kargl/
| |
| robert.corbett@sun.com 2005-02-19, 3:57 am |
| Assuming 2 is the integer kind parameter value with the largest
decimal exponent range, then, yes, the constant will effectively be
converted to an integer value whose kind type parameter value is 2
first and then that integer value will be converted to an integer value
whose kind type parameter value is 1. Assuming the range of
integer values of both kind type parameter values includes the
value 4, the value of b in your example will be 4 unless the
processor takes advantage of the clause in the standard that says
that the particular approximations to numeric values are not
specified.
Bob Corbett
| |
| Steven G. Kargl 2005-02-19, 3:57 am |
| In article <1108791728.556989.267390@z14g2000cwz.googlegroups.com>,
robert.corbett@sun.com writes:
> Assuming 2 is the integer kind parameter value with the largest
> decimal exponent range, then, yes, the constant will effectively be
> converted to an integer value whose kind type parameter value is 2
> first and then that integer value will be converted to an integer value
> whose kind type parameter value is 1. Assuming the range of
> integer values of both kind type parameter values includes the
> value 4, the value of b in your example will be 4 unless the
> processor takes advantage of the clause in the standard that says
> that the particular approximations to numeric values are not
> specified.
>
Bob,
Thanks for the comment. Your interpretation of the standard and
mine agree.
--
Steve
http://troutmask.apl.washington.edu/~kargl/
|
|
|
|
|