I just found an error in some number manipulation in my program and I get FloatDomainError (NaN)
So, I started logging the number passed with:
if(metric.is_a?(Numeric)) self.metric = metric else LOGGER.warn("metric #{metric} is not a number") self.metric=0 end
But the number that is passed is NaN , which apparently is_a?(Numeric) , since I don't get a warning about my protocol, and it passes the metric to my metric = method, where I get my FloatDomainError
Now, correct me if I'm wrong, but doesn't it seem semantically wrong to have NaN (Not A Number) of type Numeric? Can someone explain this to me?
BTW using Jruby-1.4.1
ruby numbers nan
brad
source share