I belive many other floating point functions just return `NaN`

for fast results or IEEE floating point compliance for incompatible input values but `sin`

, `cos`

like trigonometric functions throw for `Inf`

but also not throw for `NaN`

. What is the reasoning for that?

See: NaN vs wild (or, what's a DomainError, really?) · Issue #5234 · JuliaLang/julia · GitHub

Key quotes:

Operations whose results would produce NaNs should throw

`Exception`

s if the cost of testing a NaN would not dominate the cost of the operation.

NaN input can just propagate. We mostly don’t want to

produceNaNs from non-NaNs.

2 Likes

Thanks for the quick answer.