Fortran 77 Language Reference HomeContentsPreviousNextIndex


Appendix C

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

TABLE C-1   Floating-point Representation

Single Double Quadruple
Sign Bit 31 Bit 63 Bit 127
Exponent Bits 30-23
Bias 127
Bits 62-52
Bias 1023
Bits 126-112
Bias 16583
Fraction Bits 22-0 Bits 51-0 Bits 111-0
Range approx. 3.402823e+38
1.175494e-38
1.797693e+308
2.225074e-308
3.362E-4932
1.20E+4932


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:

(-1) sign * 2 1-bias *0.f

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 and DOUBLE 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.

TABLE C-2   IEEE Representation of Selected Numbers
Value Single-Precision Double-Precision
+0 00000000 0000000000000000
-0 80000000 8000000000000000
+1.0 3F800000 3FF0000000000000
-1.0 BF800000 BFF0000000000000
+2.0 40000000 4000000000000000
+3.0 40400000 4008000000000000
+Infinity 7F800000 7FF0000000000000
-Infinity FF800000 FFF0000000000000
NaN 7Fxxxxxx 7FFxxxxxxxxxxxxx


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  
Abbreviation Meaning
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
Left Operand
Right Operand

0 Sub Num Inf NaN
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
Left Operand
Right Operand

0 Sub Num Inf NaN
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
Left Operand
Right Operand

0 Sub Num Inf NaN
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
Left Operand
Right Operand

0 Sub Num Inf NaN
0
= < < < Uno
Sub
>
< < Uno
Num
> >
< Uno
Inf
> > > = Uno
NaN
Uno Uno Uno Uno Uno


Notes:

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
Byte n+3 Byte n+2 Byte n+1 Byte n
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
Byte n Byte n+1 Byte n+2 Byte n+3
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:

See also the xdr(3N) man page.


Sun Microsystems, Inc.
Copyright information. All rights reserved.
Feedback
Library   |   Contents   |   Previous   |   Next   |   Index