Re: [julia-users] issue with 0.0 = -0.0

2015-12-08 Thread Stefan Karpinski
https://github.com/JuliaLang/julia/issues/4648 On Tue, Dec 8, 2015 at 12:13 AM, Gustavo Goretkin < gustavo.goret...@gmail.com> wrote: > Similarly, > > julia> immutable bar >a::Float64 >end > > julia> bar(NaN) == bar(NaN) > true > > julia> NaN == NaN > false > > On Mon, Dec 7, 2015

Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Gustavo Goretkin
Similarly, julia> immutable bar a::Float64 end julia> bar(NaN) == bar(NaN) true julia> NaN == NaN false On Mon, Dec 7, 2015 at 8:24 PM, Seth wrote: > I was just about to post this result, which I don't understand. Why should > > 0.0 == -0.0 > > but bar(0.0) != bar(-0.0) when bar

Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Seth
I was just about to post this result, which I don't understand. Why should 0.0 == -0.0 but bar(0.0) != bar(-0.0) when bar is immutable? (yes, you can override == for this to be ==(x::bar, y::bar) = x.a == y.a, but that seems as if it should be unnecessary.) On Monday, December 7, 2015 at 5:14

Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Yichao Yu
On Mon, Dec 7, 2015 at 7:01 PM, Davide Lasagna wrote: > Cool! Thanks Also note that since your type is mutable, the default `==` is object identity and your `a` and `b` won't equal even if their content are the same by default. An `immutable` type will compare the content by default (although `-0

Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Davide Lasagna
Cool! Thanks

Re: [julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Stefan Karpinski
There are always going to be cases where you want one behavior and others where you want another. You can change this by overloading == for your type. On Mon, Dec 7, 2015 at 6:54 PM, Davide Lasagna wrote: > I understand the reason why -0.0 == 0.0, but then this should happen also > for two objec

[julia-users] issue with 0.0 = -0.0

2015-12-07 Thread Davide Lasagna
I understand the reason why -0.0 == 0.0, but then this should happen also for two objects of the same type that have 0.0 and -0.0 as the value of their single field as shown below. julia> -0.0 == 0.0 true julia> type foo a::Float64 end julia> b = foo(-0.0) foo(-0.0) jul