`Base.iszero` not fully compatible using `IntervalArithmetic` values
In their 1.0 update, the design of `IntervalArithmetic` changed so that `Base.iszero` will throw this error when value is an interval overlapping zero:
```julia
> iszero(interval(-1, 1))
ERROR: ArgumentError: `==` is purposely not supported for
overlapping non-thin intervals. See instead `isequal_interval`
```
A solution using `isthinzero` is thus suggested, which outputs `false` only if the compared value is a thin zero (no other floating-point values in the interval).
```julia
> isthinzero(interval(-0,0)) ## true
> isthinzero(interval(-0.0,0.0)) ## true
> isthinzero(interval(prevfloat(-0.0),0.0)) ## false
> isthinzero(interval(0.0,nextfloat(0.0))) ## false
```
Please consider updating compatibility with `IntervalArithmetic` again, thank you.
Note, that an `Interval` is a `Real` type, so it matches the second of the following rules (`::Number`) in your internal `_iszero` method:
```julia
@inline _iszero(x) = iszero(x) === true
@inline _iszero(x::Number) = iszero(x)
@inline _iszero(x::AbstractArray) = iszero(x)
```
关闭于 2026-01-07 1 条评论