Depending on your needs you can rely on the ieee_arithmetic module ieee_arithmetic in Fortran Wiki which already has a function for that, or you could have a read to this thread: Challenge: Testing Inf and NaN with `gfortran-13 -Ofast` for some ideas
Related topics
Topic | Replies | Views | Activity | |
---|---|---|---|---|
Checking Inf/NaN when compilers are invoked with aggressive optimization flags | 2 | 718 | September 16, 2021 | |
Challenge: Testing Inf and NaN with `gfortran-13 -Ofast`
|
38 | 1863 | October 3, 2023 | |
Is there a way to know if a variable is NaN, +infinity, -infinity?
|
25 | 6621 | May 31, 2022 | |
Is comparison with `NaN` considered an erroneous arithmetic operation? (MWE with ifort and gfortran) | 13 | 1163 | December 20, 2022 | |
Should 0.0/0.0 be NaN? | 17 | 905 | March 10, 2024 |