```On Apr 16, 2009, at 12:29 PM, Shot (Piotr Szotkowski) wrote:
>> I would have thought that z.eql?(nz) might be false. There doesn't
>> seem to be a way to query a float to distinguish between -Infinity
>> and Infinity
>
> These actually aren=92t =3D=3D, eql? nor equal?

I wasn't very clear.  My point was that you have to do two tests to =20
determine if an arbitrary float is negative infinity or positive =20
infinity.

def negative_infinity?(x)
!x.finite? and x < 0
end

I believe (but I didn't check...) there is just a single bit pattern =20
in IEEE floating point that means 'negative infinity' or 'positive =20
infinity' and so it should be implementable as a simple equality =20
comparison.  Since Ruby floats are 'boxed' values I believe that test =20=

would have to be implemented in the runtime.

>> or between -0.0 and 0.0 other than via #to_s.
>
> -0.0.equal? 0.0 # =3D> false

Yes but:

z1 =3D (0.0/1)
z2 =3D (0.0/1)
z3 =3D (0.0/-1)

z1 =3D=3D z2  # true
z1 =3D=3D z3  # true

z1.eql?(z2) # true
z1.eql?(z3) # true

z1.equal?(z2) # false
z1.equal?(z3) # false

```