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 | |
---|---|---|---|---|
Is there a way to know if a variable is NaN, +infinity, -infinity?
|
25 | 6177 | May 31, 2022 | |
Challenge: Testing Inf and NaN with `gfortran-13 -Ofast`
|
38 | 1811 | October 3, 2023 | |
Checking Inf/NaN when compilers are invoked with aggressive optimization flags | 2 | 712 | September 16, 2021 | |
LFortran now supports all intrinsic functions | 44 | 1421 | January 5, 2025 | |
Fazang: a reverse-mode automatic differentiation library | 23 | 1670 | February 24, 2023 |