I am performing some calculations in Fortran 90. A particular variable (declared as implicit double precision) is taking the value of something like -1.0420437349566899E-318
. At first, I ignored it assuming that it was probably just zero (the value that the variable is supposed to take is also zero). But now I am wondering if E-318 indicates an error in my code. I am also asking this since this variable takes such values at various points in a loop and on occasions the variable also takes NaN
as its value. This indicates that there is most certainly an error in my code but I have a different question. In general What is the maximum and minimum value that such variables can take in Fortran 90?
-1.0420437349566899E-318
means −1.0420437349566899 • 10−318, that is, approximately −1 times ten to the power of −318. “E” stands for the Exponent of ten.
This is a very small number. Its magnitude is below the smallest normal number in the IEEE-754 “double precision” floating-point format (binary64), 2−1022, which is about −1.11254•10−308. The magnitude is above the small representable number, the subnormal number 2−1074, about 4.94•10−324. When a number this small appears in results, it may be because repeated multiplications by a number smaller than one have been performed. For example, in an audio filter designed to produce an echo, with each repetition at a lower volume than the previous one, the magnitudes of previous sounds will eventually reach the subnormal range if there is no new incoming sound overriding them. It can also occur when a variable is not initialized or the bytes representing a different type of data are reinterpreted as a floating-point type.