From: furufuru@... (Ryo Furue) Date: 2004-10-16T05:54:36+09:00 Subject: Re: "nan".to_f ? Yukihiro Matsumoto wrote in message news:<1097623876.470219.23507.nullmailer@x31.priv.netlab.jp>... > Hi, > > In message "Re: "nan".to_f ?" > on Wed, 13 Oct 2004 05:22:00 +0900, Thomas Fini Hansen writes: > > |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. [...] Maybe I'm too late to jump in to this old thread (three-days old is old enough for people to forget about a thread :). Anyway, . . . I think that symmetry is important, or if not important, it's nice to have. So, *if* x = 0.0/0.0 #=> NaN x.to_s #=> "NaN" *then* y = "NaN".to_f # y *should* be NaN. In other words, I'd expect (x.to_s).to_f to be an identity operation (apart from potential truncation associated with to_s) for a Float x. I'm not saying that 0.0/0.0 *should* evaluate to NaN. That depends on the platform. What I'm saying is that whatever x.to_s evaluates to, (x.to_s).to_f "should" recover the (more-or-less) original value. By "should", I mean "I wish". Same goes for "Inf" and "-Inf". Cheers, Ryo