[ Pobierz całość w formacie PDF ]

nonnegative. A double-precision constant has a double-precision exponent and
an optional decimal point. Double-precision constants, REAL*8, use 8 bytes of
storage. The REAL*8 notation is nonstandard.
Double-Precision Exponent
A double-precision exponent consists of the letterD, followed by an optional plus
or minus sign, followed by an integer.
A double-precision exponent denotes a power of 10. The value of a double-
precision constant is the product of that power of 10 and the constant that
precedes theD. The form and interpretation are the same as for a real exponent,
except that a D is used instead of an E.
Data Types and Data Items 33
2
Examples of double-precision constants are:
1.6D-9
7D3
$1.0D2.0 Invalid  $not allowed, error message
82 NotDOUBLE PRECISION need decimal point or exponent
29,002.0D0 Invalid comma not allowed, error message
1.8D308 Invalid too large, machine infinity is used
1.0D-324 Invalid too small, some precision is lost
The restrictions are:
" Other than the optional plus or minus sign, a decimal point, the digits 0
through 9, a blank, and the letter D. No other characters are allowed.
" The magnitude of an IEEE normalized double-precision floating-point value
must be in the approximate range (2.225074D-308, 1.797693D+308).
REAL*16 (Quad Real) Constants
(SPARC only) A quadruple-precision constant is a basic real constant (see the
start of the section,  Real Constants on page 32), or an integer constant, such
that it is followed by a quadruple-precision exponent.
A quadruple-precision exponent consists of the letter Q, followed by an optional
plus or minus sign, followed by an integer.
A quadruple-precision constant can be positive, negative, or zero. If no sign is
present, the constant is assumed to be nonnegative.
Example: Quadruple-precision constants (SPARC only):
1.6Q-9
7Q3
3.3Q-4932
1.1Q+4932
$1.0Q2.0 Invalid $not allowed, error message
82 Notquad need exponent
29,002.0Q0 Invalid comma not allowed, error message
1.6Q5000 Invalid too large, machine infinity is used
1.6Q-5000 Invalid too small, some precision is lost
34 FORTRAN 77 Reference Manual
2
The form and interpretation are the same as for a real constant, except that a Q
is used instead of an E.
The restrictions are:
" Other than the optional plus or minus sign, a decimal point, the digits 0
through 9, a blank, and the letter Q. No other characters are allowed.
" The magnitude of an IEEE normalized quadruple-precision floating-point
value must be in the approximate range (3.362Q-4932, 1.20Q+4932).
" It occupies 16 bytes of storage.
" Each such datum is aligned on 4-byte boundaries.
Typeless Constants (Binary, Octal, Hexadecimal)
Typeless numeric constants are so named because their expressions assume
data types based on how they are used.
These constants are not converted before use. However, in f77, they must be
distinguished from character strings.
The general form is to enclose a string of appropriate digits in apostrophes and
prefix it with the letter B, O, X, or Z. The B is for binary, the O is for octal, and
the X or Z are for hexadecimal.
Example: Binary, octal, and hexadecimal constants, DATA and PARAMETER:
PARAMETER ( P1 = Z'1F' )
INTEGER*2 N1, N2, N3, N4
DATA N1 /B'0011111'/, N2/O'37'/, N3/X'1f'/, N4/Z'1f'/
WRITE ( *, 1 ) N1, N2, N3, N4, P1
1 FORMAT ( 1X, O4, O4, Z4, Z4, Z4 )
END
Note the edit descriptors in FORMAT statements: O for octal, and Z for
hexadecimal. Each of the above integer constants has the value 31 decimal.
Data Types and Data Items 35
2
Example: Binary, octal, and hexadecimal, other than inDATA andPARAMETER:
INTEGER*4 M, ICOUNT/1/, JCOUNT
REAL*4 TEMP
M = ICOUNT + B'0001000'
JCOUNT = ICOUNT + O'777'
TEMP = X'FFF99A'
WRITE(*,*) M, JCOUNT, TEMP
END
In the above example, the context defines B'0001000' and O'777' as
INTEGER*4 and X'FFF99A' as REAL*4. For a real number, using IEEE
floating-point, a given bit pattern yields the same value on different
architectures.
The above statements are treated as the following:
M = ICOUNT + 8
JCOUNT = ICOUNT + 511
TEMP = 2.35076E-38
Control Characters
You can enter control characters with typeless constants, although the CHAR
function is standard, and this way is not.
Example: Control characters with typeless constants:
CHARACTER BELL, ETX / X'03' /
PARAMETER ( BELL = X'07' )
Alternate Notation for Typeless Constants
For compatibility with other versions of FORTRAN 77, the following alternate
notation is allowed for octal and hexadecimal notation. This alternate does not
work for binary, nor does it work in DATA or PARAMETER statements.
For an octal notation, enclose a string of octal digits in apostrophes and
append the letter O.
36 FORTRAN 77 Reference Manual
2
Example: Octal alternate notation for typeless constants:
'37'O
37'O Invalid missing initial apostrophe
'37' Not numeric missing letterO
'397'O Invalid invalid digit
For hexadecimals, enclose a string of hex digits in apostrophes and append the
letter X.
Example: Hex alternate notation for typeless constants:
'ab'X
3fff'X
'1f'X
'1fX Invalid missing trailing apostrophe
'3f' Notnumeric missingX
'3g7'X Invalid invalid digitg
Here are the rules and restrictions for binary, octal, and hexadecimal constants:
" These constants are for use anywhere numeric constants are allowed.
" These constants are typeless. They are stored in the variables without any
conversion to match the type of the variable, but they are stored in the
appropriate part of the receiving field low end, high end.
" If the receiving data type has more digits than are specified in the constant,
zeros are filled on the left.
" If the receiving data type has fewer digits than are specified in the constant,
digits are truncated on the left. If nonzero digits are lost, an error message is
displayed.
" Specified leading zeros are ignored.
" You can specify up to 8 bytes of data for any one constant at least that's all
that are used. [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • sloneczny.htw.pl