[#23231] What do you think about changing the return value of Kernel#require and Kernel#load to the source encoding of the required file? — =?ISO-8859-15?Q?Wolfgang_N=E1dasi-Donner?= <ed.odanow@...>

Dear Ruby developers and users!

8 messages 2009/04/17

[#23318] [Feature #1408] 0.1.to_r not equal to (1/10) — Heesob Park <redmine@...>

Feature #1408: 0.1.to_r not equal to (1/10)

19 messages 2009/04/26

[ruby-core:23223] Re: [Bug #1336] Change in string representation of Floats

From: Gary Wright <gwtmp01@...>
Date: 2009-04-17 01:14:20 UTC
List: ruby-core #23223
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稚 ==, eql? nor equal?

I wasn't very clear.  My point was that you have to do two tests to  
determine if an arbitrary float is negative infinity or positive  
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  
in IEEE floating point that means 'negative infinity' or 'positive  
infinity' and so it should be implementable as a simple equality  
comparison.  Since Ruby floats are 'boxed' values I believe that test  
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 # => false

Yes but:

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

z1 == z2  # true
z1 == z3  # true

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

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


In This Thread