What checks should I do to know if the result of a mathematical operation is a valid number? (I can’t use isfinite with the struct I’m using)
isnan(), == Inf, == -Inf
Any other values?
isfinite is defined as: isfinite(x::AbstractFloat) = x - x == 0
1 Like
isfinite is what you want to check whether something is an “ordinary” floating-point number (as opposed to ±Inf or NaN). (If you can’t use isfinite, how do you plan to use isnan?)
You could always call isfinite on the fields of your struct, or define a new isfinite method that does this for you.
2 Likes