Feature Request - [CanBeNaN] and [NotNaN], floating point equivalent to [CanBeNull] and [NotNull]

When programming [CanBeNull] and [NotNull] used in conjunction with R#'s code analysis engine is a huge timesaver.

However, it would be nice to have a similar feature for dealing with odd floating point arithmetic cases, where "scary" values can emerge, like NaN and Infinity. Like Null, NaN and Infinity can have similarly catastrophic consequences if not checked for.

Consider attributes like these:

[CanBeNaN] [NotNaN]
[CanBeInfinity] [NotInfinity]

Also, these attributes may be a good idea, but they may also be too cluttered.

[CanBeZero] [NotZero] - a value with [NotZero] is always safe to divide with. 
[CanBeNegative] [NotNegative] - a value with [NotNegative] is always safe to use in Sqrt().

However, the main issue with attributes like these that I can think of is that theoretically there are many mathematical functions (sqrt(x), 1/x, etc.) that produce undefined output values with certain input values, and it wouldn't necessarily make sense to make special attributes for all of them. However division is common, so perhaps it may be warranted on those grounds alone.

What do you think?

Please sign in to leave a comment.