Comparison using == still works as expected, so big(1) == big(1), but this does not extend to comparing structs that contain BigInt or BigFloat (unless == is explicitly overloaded) because == defaults to ===.
julia> immutable T
x::BigInt
end
julia> T(1) == T(1)
false
Is there a reason for this behavior, or it it a bug?
(I’ve tried this under 0.5.1 and 0.6.0-pre.alpha.76.)
=== is for comparing identity, not for comparing values. This is not a bug and is expected given that BigInt and BigFloat are mutable types.
The fact that BigFloat and BigInt are implemented as mutable types and therefore can be distinguished even when two objects holds the same value is an implementation detail that you shouldn’t need to care about if you just want to write generic code that handles numbers. If you are doing something specific to these types and somehow cares about their identity then you’ll need too handle this.
If they are considered numbers, they should be immutable and === should work: this has already been discussed (here for example).
The implementation detail is the underlying C library and for performance reason I understand that it is better to reuse the space allocated, making the type mutable.