Richard Maine wrote:
>
> Alberto Fasso' writes:
> > Well, but this only changes the question, doesn't it?
> > Why "binary, octal and hexadecimal values may be stored, via a DATA
> > statement, only in integers"?
>
> Because they are mathematically integers. They are just integers
> expressed in bases other than 10. They aren't defined as bit
> patterns. There is nothing magic about base 16 that makes it
> inherently a bit pattern. (It just happens to be a base that's easy
> to convert to binary in your head). You'll find nowhere in the
> standard that says anything about the bit-level representation of
> these, any more than you will find anything about the bit-level
> representation of integer constants written in decimal form. These
> are just other forms for writing literal integer constants. At least
> that's the way the standard treats them.
>
> Of course, I'm aware that it can be useful, or even necessary, to
> work with bit-level representation at times. This tends to require
> stepping outside of the bounds of the standard. Even though you might
> use syntax defined by the standard (such as the TRANSFER intrinsic),
> the result is pretty much bound to be processor-dependent insomuch as
> the bit-level representations are processor-dependent.
>
> I wouldn't mind seeing the standard be a little more helpful in
> providing standard syntax to spell more things which, like TRANSFER,
> have processor-dependent results. But it's currently a bit short
> in those areas.
>
> Much more detailed answers to "why" are going to be, as usual,
> difficult to answer in any meaningful fashion (assuming that
> you don't count "just because" as meaningful.)
>
All the more reason for defining true bit stream/boolean data types so
that I can manipulate bits without going outside the standard and know
specifically what results I'll get. 99.99% of all use of Fortran in my
industry would not be possible if most if not all Fortran compilers did
not do as you would expect when using (e.g.) hex constants in an integer
assignment statement (so that I can subsequently manipulate them in
boolean/logical fashion).
> --
> Richard Maine | Good judgement comes from experience;
> [log in to unmask] | experience comes from bad judgement.
> | -- Mark Twain
--
Gary Scott
mailto:[log in to unmask]
mailto:[log in to unmask]
http://www.fortranlib.com
Support the GNU Fortran G95 Project: http://g95.sourceforge.net
|