Re: Select case restrictions
From: Ron Shepard (ron-shepard_at_NOSPAM.comcast.net)
Date: 12/20/04
- Next message: Michael Prager: "Re: Question about edit descriptors"
- Previous message: Merrill & Michele: "Re: small numerical differences in floating point result between wintel and Sun/SPARC"
- In reply to: Herman D. Knoble: "Re: Select case restrictions"
- Next in thread: James Van Buskirk: "Re: Select case restrictions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 20 Dec 2004 10:37:28 -0600
In article <jvsds09r8kskkh9np64lr3u9v698b46ctp@4ax.com>,
Herman D. Knoble <SkipKnobleLESS@SPAMpsu.DOT.edu> wrote:
> Question: Is it valid to input (or assign) a number x bigger
> than ik1 = selected_int_kind(2) ?
I'm not sure I'm replying to the question that you asked, but if it
is about the argument of selected_int_kind(), then suppose on a
particular computer that selected_int_kind(2) is the same as
selected_int_kind(9) or selected_int_kind(18). That is, suppose the
machine supported only 32-bit or 64-bit integers, and nothing
smaller. For that machine, I think it would be legal to read or
assign a number larger than 99. However, on a machine that
supported 8-bit integers, then assignment of values larger than 127
would fail. Note that the limit would be 127, the actual limit for
that data type, not 99, the requested limit. So I think the answer
is that it is legal, because a compiler is allowed to support larger
integers than requested, but nonportable, because it is not required
to support larger integers. If you want portability of the fortran
source code, then the assignments would have to be small enough to
fit within the requested range.
It has been discussed here in the past in c.l.f. that the
decimal-based requests are not consistent with the binary-based
actual data types. That is, if you want to assign values up to 127,
then there is no way to use selected_int_kind() to return an 8-bit
integer type that covers exactly that desired range of values. If
you request a 2-digit range, then the numbers between 100 and 127
would be outside of the requested range, but if you request a
3-digit range, the compiler is required to return a type that would
support values up to 999, which of course will not fit in an 8-bit
integer type, so a larger type would be returned. So in practice
you have to request the 2-digit integer type with
selected_int_kind(2), and trust that the compiler will return the
8-bit integer that you really want.
The proposed solutions to this problem have included additional
arguments to the selected_int_kind() function to specify either the
number of bits or to specify the base in which the number of digits
is to be interpreted.
$.02 -Ron Shepard
- Next message: Michael Prager: "Re: Question about edit descriptors"
- Previous message: Merrill & Michele: "Re: small numerical differences in floating point result between wintel and Sun/SPARC"
- In reply to: Herman D. Knoble: "Re: Select case restrictions"
- Next in thread: James Van Buskirk: "Re: Select case restrictions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|