c# - Comparing NaN and null returns illogic value -


why following code snippet returns 1:

double = double.nan; double? i2 = null; i.compareto(i2); 

from point of view makes no sense. exception more appropriate.

what think reasoning behind decision.

from documentation on compareto:

the value parameter must null or instance of double; otherwise, exception thrown. instance of double, regardless of value, considered greater null.

the value parameter in example null. nan therefore considered greater null why compareto correctly returns 1.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -