From: Hiro Asari Date: 2012-01-12T10:14:28+09:00 Subject: [ruby-core:42076] [ruby-trunk - Bug #5884] Float::NAN and 0.0/0.0 is represented differently when packed with 'g' Issue #5884 has been updated by Hiro Asari. I am not presenting a real use case. That is not my intent. My intent is to clarify the design of Float::NAN, especially in relation to 0.0/0.0. Since there is no way to distinguish the two without it, it seems to me that Array#pack is as good a use case as any. It is useful to the extent that we can distinguish the two, now that it is established that they can (and perhaps *should*) be different. I see that my assumption that these objects should behave the same was flat out misguided. It is acknowledged that there are many NaN's. As there is no way to distinguish these multiple NaN values that are passed to Array#pack, then, am I correct to conclude that [Float::NAN].pack("g"), as well as [0.0/0.0].pack("g"), is indeterminate? Also, am I correct to conclude that the value generated on one machine may not be identical to the one that is generated on another? (I understand that this is mostly academic; the two different values make a round trip correctly in and out of their respective packed counterpart, one way or another.) ---------------------------------------- Bug #5884: Float::NAN and 0.0/0.0 is represented differently when packed with 'g' https://bugs.ruby-lang.org/issues/5884 Author: Hiro Asari Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0dev (2011-12-31 trunk 34165) [x86_64-darwin11.2.0] $ ruby2.0 -e 'p [Float::NAN].pack("g")' "\x7F\xC0\x00\x00" $ ruby2.0 -e 'p [0.0/0.0].pack("g")' "\xFF\xC0\x00\x00" It would be nice to have Float::NAN and 0.0/0.0 behave identically in this regard. -- http://bugs.ruby-lang.org/