From: GOTO Kentaro Date: 2004-10-16T03:39:51+09:00 Subject: Re: "nan".to_f ? In message Re: "nan".to_f ? on Fri, 15 Oct 2004 03:05:16 +0900, Markus: > My mistake is clear. I was assuming Float == IEEE. Mistake? I don't think you mistook. or I also mistake. When we are talking about Ruby, NaN means IEEE 754's NaN, isn't it? :) > I still see the original poster's desire to be able to serialize > floats as text without gross changes, but do not at this point see a > clear and portable way of implementing it. At best (using the code I > posted yesterday morning) you could maintain the distinction between > error-values and numbers, but this might well silently morph (say) Inf > to NaN, etc. NaN was designed to represent abnormal result of an arithmetic operation. So, IMHO, String#to_f is not arithmetic and should not returns NaN. By the way, we sometimes want to define a method return NaN value. In such situations I believe pack/unpack will help. Gotoken