1.#QNAN error C++

后端 未结 1 974
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 03:38

I am new to programming and trying to write a new program. While checking through my program it is returning the error code 1.#QNAN. I have tried isolating the variable an

1条回答
  •  爱一瞬间的悲伤
    2020-12-14 04:03

    1#QNAN is a string representation for a "quiet NAN". A "NAN" is "not-a-number" and applies only to floats and doubles.

    NANs can be very useful actually for representing "null" values (rather than picking some genuine number and hoping for the best you don't need that number for its natural meaning).

    Some mathematical operations can return a NAN if the operation is "not valid" (eg taking the log of a negative number).

    You can generate a QNAN from C++ using

    double d = std::numeric_limits::quiet_NaN();
    

    Any comparison operation (==, <= etc) on a NAN returns false, even comparing its equality to itself, except for != which always returns true (even when comparing to itself).

    (The actual bug in your code appears to be a function that returns double but has no return statement).

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