I'm writing a ray tracer and part of the process is firing a ray that may or may not hit an object (geometric object). A number of the equations that describe objects return NaN naturally if no intersection happened (the intersection is imaginary) but not all of the objects return NaN if no intersection happened.
I know that I could force returning sqrt(-1) if no intersection happened, but I was wondering if there is a way to return this in a less expensive way.