From: Thomas Fini Hansen Date: 2004-10-13T05:22:00+09:00 Subject: Re: "nan".to_f ? On Wed, Oct 13, 2004 at 01:49:37AM +0900, Stephan K�mper wrote: > Mikael Brockman wrote: > >> Yes, but his point is that "NaN" _is_ the string representation of > >>valid floating point value, defined and handled by the system, with > >>standardized semantics, etc. > >> "NaN".to_f should return NaN. How else are you going to reliably > >>get NaN if you need it? > > When would you *need* NaN in the first place? To show the the result of > some calculation is NaN? The just return that calculation. Well, my case was pretty simple, I'm parsing the output of RRDTool, which uses floats internally, and writes 'nan' for unknown data. > To test whether something is NaN? -> There's Float#nan? to do that. Well, that was what I wanted to do, later, but now I have to check for the string 'nan' at parse time, or else I'll get 0.0, when it's not quite. 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*. Not that it's an unsurmountable problem for what I'm doing, it's just nicer and cleaner. -- Thomas beast@system-tnt.dk