Floating point exception when reading real values from an input file

后端 未结 1 394
南方客
南方客 2021-01-21 18:18

I try to read a float value from an input file in Fortran.

To do so I use this code :

...
INTEGER            :: nf
REAL               :: re
         


        
1条回答
  •  孤城傲影
    2021-01-21 18:31

    The floating point exceptions inexact and denormal happen way too often and during legitimate use of floating point arithmetic is inexact. Almost all real-world floating point arithmetic. Even reading a single number from file or keyboard, because not all decimal numbers can be stored exactly in binary. Denormal happens slightly less often, but the use can still be legitimate.

    Therefore it is not useful to trap these floating point exceptions. Even underflow is debatable. I would not trap it by default, but I can see its usefulness.

    0 讨论(0)
提交回复
热议问题