Re: BOZ literal constants, a puzzle for us Standard-loving types.



glen herrmannsfeldt wrote:
Steven G. Kargl wrote:

(snip)

There are no negative integers in gfortran. There is a unary
minus operator and whole numbers. :)


Traditionally DATA statements were maybe the only place where
signed constants were allowed. In F2003:

data-stmt-constant is scalar-constant
or scalar-constant-subobject
or signed-int-literal-constant
or signed-real-literal-constant
or null-init
or structure-constructor

Bit patterns for reals can be done with TRANSFER. Yes, it isn't
portable, but REAL(BOZ) isn't portable either. I'm almost tempted
to suggest that J3 was smoking crack when it approved using BOZs
in REAL, INT, and CMPLX. It appears to be a broken attempt to fix the broken semantics of TRANSFER.


Maybe a concession to the fact that no solution is perfect,
but sometimes you need to do it anyway. I suppose I like the
REAL form better than just putting Z constants into DATA statements,
as some compilers used to allow. As far as I know, OS/360 Fortran
is the beginning of Z constants and the Z format descriptor.
(The more obvious X format descriptor already taken.)

and the even more obvious "H" format...(for hex)


-- glen



--

Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows it can't be done.

-- Henry Ford
.



Relevant Pages

  • Re: BOZ literal constants, a puzzle for us Standard-loving types.
    ... data-stmt-constant is scalar-constant ... I distinctly remember that Richard Maine told me I was splitting the standard's hairs far too fine when I suggested that this meant that an integer equal to -HUGE-1 ought to be allowable in DATA statements even though it's an overflow elsewhere. ... is the beginning of Z constants and the Z format descriptor. ...
    (comp.lang.fortran)
  • Re: Embedding data in executable
    ... In order to distribute the executable, I need to hide the database contents to the final user, because the database informations are confidential. ... If the database size exceeds your compiler's limitations for data statements, I think that I might devise a means of encrypting the data and sending it along in an encrypted file that cannot be read by the end user. ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)