Re: SELECTED_REAL_KIND clarification plse
From: Richard E Maine (nospam_at_see.signature)
Date: 10/05/04
- Next message: Dave Seaman: "Re: 0.0**0 = ?"
- Previous message: Kamaraju Kusumanchi: "Re: SELECTED_REAL_KIND clarification plse"
- In reply to: dud_address_at_xparadise.net.nz: "SELECTED_REAL_KIND clarification plse"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 05 Oct 2004 09:05:39 -0700
dud_address@xparadise.net.nz writes:
[questions about SELECTED_REAL_KIND & SELECTED_INT_KIND]
I think others have given you reasonably good answers, and for
that matter, it looks like you had it about right in the first place,
even if you found it a bit strange.
Be aware that these intrinsics are not specific to byte-based
architectures. The language didn't even used to have a hint of
reference to things like bytes (and machine data sizes varied much
more than they tend to today). In a *VERY* few places (one that I can
think of), there are now references to bytes (well, octets in
standard-speak), but even that is just a recommendation.
So yes, in practice, selected_int_kind(4) will get you 16-bit integers
because that's highly likely to be the smallest integer size that
supports the erquired range. A processor *COULD* provide a
decimal integer that actually had a range of only -9999 to +9999,
but none actually do.
The Fortran standard doesn't directly provide a way to specify that
you really want an integer of exactly 16 bits. As of f2003, there
is a "back door" way through C interop in that C provides a way to
ask for exactly 16 bits, and C interop provides a Fortran binding to
that C capability (with c_int16_t). A processor isnt't required to
provide this type (and hardware might not even support it), but in
practice, it is a good bet. On the other hand, it is currently an
equally good bet that selected_int_kind(4) will get it. If compilers
start supporting decimal-based integers, then you might see a difference,
but I don't forsee that soon.
> To be honest this seems messy. It would help to have a portable
> option to directly specify a 1, 2, 4 or 8 byte integer (or 4, 8, or 16
> byte real), with the compiler providing the maximum number size /
> precision for the specified number of bytes (or specify by number of
> bits if "bytes" are not portable). I realise there are decimal
> precision vs exponent range issues for reals, but that could readily
> be covered. My 2c worth anyway.
I quite agree. I submitted a proposal along these lines for f2003+.
To me, it is mostly a matter of making things simpler for the user
instead of adding new capability. An awful lot of users come in knowing
that what they want is, for example, a 64-bit real. It takes some
arthmetic for them to figure out how to ask for this using
selected_real_kind. And conversely, it takes arithmetic to look
at the resulting call to selected_real_kind and figure out that
it gets the 64-bit real. The capability is there, but I find it
awkward and hard to read (and evidence is pretty strong that so do
a lot o users). So, although I don't want to get rid of the
existing capability, I'd like to augment it with a simple way of
specifying the most common stuff. There are a few ways to do that,
including such things as allowing a form of selected_*_kind that
allows specification of bit or byte requirements. However, I'm
leaning towards just providing a few standard named constants (like
we now do for the C interop stuff). That would be completely
trivial to implement.
Hmm. I haven't been to the last few meetings. In checking the
status of my proposal, it looks to have been accidentally "lost"
(by combining it with another somewhat related proposal... but
then failing to actually address it in work on the allegedly
combined proposal). Time for a little prod, I guess.
-- Richard Maine | Good judgment comes from experience; email: my first.last at org.domain | experience comes from bad judgment. org: nasa, domain: gov | -- Mark Twain
- Next message: Dave Seaman: "Re: 0.0**0 = ?"
- Previous message: Kamaraju Kusumanchi: "Re: SELECTED_REAL_KIND clarification plse"
- In reply to: dud_address_at_xparadise.net.nz: "SELECTED_REAL_KIND clarification plse"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|