KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
What's the best way to use NaNs in C++? I found std::numeric_limits<double>::quiet_NaN() and std::numeric_limits<double>::signaling_NaN() . I'd like to use signaling_NaN to represent an uninitialized variable as follows: double diameter = std::numeric_limits<double>::signaling_NaN(); This, however, signals (raises an exception) on assignment. I want it to raise an exception on use, not on assignment. Is there any way to use signaling_NaN without raising an exception on assignment? Is there a good, portable alternative to signaling_NaN that will raise a floating point exception when used?
Tags (comma-separated)
Save Edits
Cancel