0

Of the five floating point exception categories defined in C++, namely:

  1. FE_INEXACT
  2. FE_DIVBYZERO
  3. FE_UNDERFLOW
  4. FE_OVERFLOW
  5. FE_INVALID

...which of these can result in a NaN value?

Also - are there any operations that can result in a NaN value, but not trigger one of these exceptions?

phuclv
  • 37,963
  • 15
  • 156
  • 475
Andrew Tomazos
  • 66,139
  • 40
  • 186
  • 319
  • Regarding your second question, there is an overload for ```quiet_NaN``` which is noexcept (actually the only one since C++11): https://en.cppreference.com/w/cpp/types/numeric_limits/quiet_NaN – Jose Jun 27 '21 at 21:48
  • @Jose: I don't think `noexcept` is relevant here. Floating point exceptions and regular C++ exceptions are unrelated. – Andrew Tomazos Jun 27 '21 at 21:51
  • 1
    Might want to specify whether you’re referring to the vague guarantees provided by the C++ standard, or by the more stringent guarantees of those which assert `is_iec559`. – Sneftel Jun 27 '21 at 21:54
  • @Sneftel: An answer for each of those two cases would be welcome. – Andrew Tomazos Jun 27 '21 at 22:03
  • It's not two cases, it's one case and a thousand other cases. – Eljay Jun 27 '21 at 22:39
  • @Eljay: By the two cases I mean whether `is_iec559` is `true` or `false` as @Sneftel highlighted. – Andrew Tomazos Jun 27 '21 at 22:41

0 Answers0