From: Markus Date: 2004-10-15T03:05:16+09:00 Subject: Re: "nan".to_f ? My mistake is clear. I was assuming Float == IEEE. 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. -- Markus On Thu, 2004-10-14 at 09:44, GOTO Kentaro wrote: > Hi, > > In message "Re: "nan".to_f ?" > on Thu, 14 Oct 2004 02:39:43 +0900, Yukihiro Matsumoto wrote: > > | 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. > > > > If the platform uses IEEE floating number, right? > > Agreed! And if there exists NaN on a non IEEE platform, > that NaN must be another concept because NaN is defined in > IEEE 754. > > > Gotoken