Fortran 77 Language Reference |
Data Representations
Whatever the size of the data element in question, the most significant bit of the data element is always stored in the lowest-numbered byte of the byte sequence required to represent that object.
This appendix is a brief introduction to data representation. For more in-depth explanations, see the Sun WorkShop Fortran Programming Guide and Numerical Computation Guide.
Real, Double, and Quadruple Precision
Real, double precision, and quadruple precision number data elements are represented according to the IEEE standard by the following form, where f is the bits in the fraction. Quad is SPARC only.
(-1)sign * 2exponent-bias *1.f
Extreme Exponents
The representations of extreme exponents are as follows.
Zero (signed)
Zero (signed) is represented by an exponent of zero and a fraction of zero.
Subnormal Number
The form of a subnormal number is:
where f is the bits in the significand.
Signed Infinity
Signed infinity--that is, affine infinity--is represented by the largest value that the exponent can assume (all ones), and a zero fraction.
Not a Number (NaN)
Not a Number (NaN) is represented by the largest value that the exponent can assume (all ones), and a nonzero fraction.
Normalized
REAL
andDOUBLE
PRECISION
numbers have an implicit leading bit that provides one more bit of precision than is stored in memory. For example, IEEE double precision provides 53 bits of precision: 52 bits stored in the fraction, plus the implicit leading 1.IEEE Representation of Selected Numbers
The values here are as shown by
dbx
, in hexadecimal.
Arithmetic Operations on Extreme Values
This section describes the results of basic arithmetic operations with extreme and ordinary values. We assume all inputs are positive, and no traps, overflow, underflow, or other exceptions happen.
TABLE C-3 Extreme Value Abbreviations Sub Subnormal number Num Normalized number Inf Infinity (positive or negative) NaN Not a Number Uno Unordered
TABLE C-4 Extreme Values: Addition and Subtraction 0 0 Sub Num Inf NaN Sub Sub Sub Num Inf NaN Num Num Num Num Inf NaN Inf Inf Inf Inf Note NaN NaN NaN NaN NaN NaN NaN
Note: Inf ± Inf and Inf + Inf = Inf ; Inf - Inf = NaN.
TABLE C-5 Extreme Values: Multiplication 0 0 0 0 NaN NaN Sub 0 0 NS Inf NaN Num 0 NS Num Inf NaN Inf NaN Inf Inf Inf NaN NaN NaN NaN NaN NaN NaN
In the above table, NS means either Num or Sub result possible.
TABLE C-6 Extreme Values: Division 0 NaN 0 0 0 NaN Sub Inf Num Num 0 NaN Num Inf Num Num 0 NaN Inf Inf Inf Inf NaN NaN NaN NaN NaN NaN NaN NaN
TABLE C-7 Extreme Values: Comparison 0 = < < < Uno Sub > < < Uno Num > > < Uno Inf > > > = Uno NaN Uno Uno Uno Uno Uno
- If either
X
orY
is NaN, thenX.NE.Y
is.TRUE.
, and the others (.EQ.
,.GT.
,.GE.
,.LT.
,.LE.
) are.FALSE.
- +0 compares equal to -0.
- If any argument is NaN, then the results of
MAX
orMIN
are undefined.Bits and Bytes by Architecture
The order in which the data--the bits and bytes--are arranged differs between VAX computers on the one hand, and SPARC computers on the other.
The bytes in a 32-bit integer, when read from address n, end up in the register as shown in the following tables.
TABLE C-8 Bits and Bytes for Intel and VAX Computers 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 Most Significant Least significant
TABLE C-9 Bits and Bytes for 680x0 and SPARC Computers 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 Most Significant Least significant
The bits are numbered the same on these systems, even though the bytes are numbered differently.
Following are some possible problem areas:
- Passing binary data over the network. Use External Data Representation (XDR) format or another standard network format to avoid problems.
- Porting raster graphics images between architectures. If your program uses graphics images in binary form, and they have byte ordering that is not the same as for images produced by SPARC system routines, you must convert them.
- If you convert character-to-integer or integer-to-character between architectures, you should use XDR.
- If you read binary data created on an architecture with a different byte order, then you must filter it to correct the byte order.
Sun Microsystems, Inc. Copyright information. All rights reserved. Feedback |
Library | Contents | Previous | Next | Index |