From: Markus Date: 2004-10-13T21:18:38+09:00 Subject: Re: "nan".to_f ? > |I would say that 'NaN' is a the string representation of a float, so > |logically it should be parsed to such, that's why I'm wondering why > |this behaviour was *removed*. > It's not valid string representation of a float. Then why does: x = 0.0/0.0 x.class #Float x.to_s #NaN If "NaN" is not the valid string representation of a Float, why does calling Float#to_s return it? > Ruby used to use system's strtod(3), which gives you "nan" an > "inf" for free, but its interpretation varies a little from platform > to platform. Now it uses its own version of strtod that interprets > only valid float representation in Ruby. The problem with this (in addition to some of my other contrived examples, e.g. the non-convergent infinite series) is that we may want to convert values to text and back (e.g., making XML) and would like to be able to get something resembling the original values back. Admittedly, it would be possible for users who wanted this to do it themselves, but the performance consequences could be considerable. -- Markus