Check whether a floating-point value is a number at all with Float's nan?
val = 1.0 val.nan? # => false val = 0.0/0.0 val.inspect # => "NaN" val.nan? # => true