C++: Comparing list of doubles with some invalid values (QNAN)

Posted by J.M. on Stack Overflow See other posts from Stack Overflow or by J.M.
Published on 2011-01-10T10:46:13Z Indexed on 2011/01/10 10:53 UTC
Read the original article Hit count: 240

Filed under:
|
|
|
|

Hello, i need to compare two std::list < double >, but some doubles may be invalid numbers (QNAN). If any invalid numbers are list entries the compare process won't work, because a comparison of the same invalid value will always result in 'false'. What is the easiest and most elegant way to solve the problem?

My idea was to create copies of both lists, iterate through them and remove invalid values and then compare the remaining lists. The lists will typically have 20-50 values in them. Is there a more resource friendly way to solve it?

© Stack Overflow or respective owner

Related posts about c++

Related posts about list