From: GOTO Kentaro Date: 2004-10-13T23:33:53+09:00 Subject: Re: "nan".to_f ? In message Re: "nan".to_f ? on Wed, 13 Oct 2004 21:38:22 +0900, Yukihiro Matsumoto wrote: > Although we can tell whether a float value is NaN by using isnan(), > but as far as I know there's no portably way to generate NaN. I think > it's not guaranteed that 0.0/0.0 generate NaN. def aNaN s, e, m = rand(2), 2047, rand(2**52-1)+1 [sprintf("%1b%011b%052b", s,e,m)].pack("B*").unpack("G").first end I believe this will generate NaN on environments where pack/unpack works and NaN exists. Gotoken