If I store -0.0
as array element of a SparseVector
, it depends on the history of modifications, whether I retrieve -0.0
or 0.0
:
julia> A = sparse([0.0;0.0])
2-element SparseVector{Float64,Int64} with 0 stored entries
julia> A[1] = -0.0; A[1]
0.0
julia> A[1] = 1; A[1] = -0.0; A[1]
-0.0
While it is clear to me, why this happens, it looks like inconsistent behaviour. When I store -0.0
I expect
- either the negative sign is always preserved
- or the
-0.0
is always replaced by0.0
Is that a bug or a feature? In the first case, we should change the implementation. In the second case, we should document it somehow.