Fortran 中变量取值 E-318 的含义
我正在 Fortran 90 中执行一些计算。特定变量(声明为隐式双精度)正在获取类似 -1.0420437349566899E-318
的值。起初,我忽略了它,假设它可能只是零(变量应该采用的值也为零)。但现在我想知道 E-318 是否表明我的代码中有错误。我也问这个问题,因为这个变量在循环中的各个点采用这样的值,并且有时该变量也采用 NaN 作为其值。这表明我的代码中肯定存在错误,但我有一个不同的问题。一般来说,Fortran 90 中此类变量可以采用的最大值和最小值是多少?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
-1.0420437349566899E-318
表示−1.0420437349566899 • 10−318,即大约−1 乘以10 的−318 次方。 “E”代表十的指数。这是一个非常小的数字。其大小低于 IEEE-754“双精度”浮点格式(binary64)中的最小正常数,2−1022,约为−1.11254•10 −308。其幅度高于可表示的小数,即次正常数 2−1074,约为 4.94•10−324。当结果中出现如此小的数字时,可能是因为重复执行了小于 1 的数字的乘法。例如,在设计用于产生回声的音频滤波器中,每次重复的音量都低于前一次,如果没有新的传入声音覆盖它们,则先前声音的幅度最终将达到低于正常范围。当变量未初始化或表示不同类型数据的字节被重新解释为浮点类型时,也可能会发生这种情况。
-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.