Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "real*8" mean?

The manual of a program written in Fortran 90 says, "All real variables and parameters are specified in 64-bit precision (i.e. real*8)."

According to Wikipedia, single precision corresponds to 32-bit precision, whereas double precision corresponds to 64-bit precision, so apparently the program uses double precision.

But what does real*8 mean?

I thought that the 8 meant that 8 digits follow the decimal point. However, Wikipedia seems to say that single precision typically provides 6-9 digits whereas double precision typically provides 15-17 digits. Does this mean that the statement "64-bit precision" is inconsistent with real*8?

like image 420
Andrew Avatar asked May 09 '12 17:05

Andrew


People also ask

What does real 8 mean?

A REAL(8) or DOUBLE PRECISION constant has more than twice the accuracy of a REAL(4) number, and greater range. A REAL(8) or DOUBLE PRECISION constant occupies eight bytes of memory. The number of digits that precede the exponent is unlimited, but typically only the leftmost 15 digits are significant.

How many bits is a REAL8?

> but REAL4 is 32 bits wide, REAL8 is 64 bits and a FLOAT is 80.

What is real in Fortran?

The REAL statement specifies the type of a symbolic constant, variable, array, function, or dummy function to be real, and optionally specifies array dimensions and size, and initializes with values.

What is implicit real in Fortran?

An IMPLICIT statement specifies a type and size for all user-defined names that begin with any letter, either a single letter or in a range of letters, appearing in the specification. An IMPLICIT statement does not change the type of the intrinsic functions.


1 Answers

The 8 refers to the number of bytes that the data type uses.

So a 32-bit integer is integer*4 along the same lines.

A quick search found this guide to Fortran data types, which includes:

The "real*4" statement specifies the variable names to be single precision 4-byte real numbers which has 7 digits of accuracy and a magnitude range of 10 from -38 to +38. The "real" statement is the same as "real*4" statement in nearly all 32-bit computers.

and

The "real*8" statement specifies the variable names to be double precision 8-byte real numbers which has 15 digits of accuracy and a magnitude range of 10 from -308 to +308. The "double precision" statement is the same as "real*8" statement in nearly all 32-bit computers.

like image 74
Jon Skeet Avatar answered Sep 29 '22 19:09

Jon Skeet