unageek / inari

A Rust implementation of interval arithmetic (IEEE 1788)
MIT License
32 stars 2 forks source link

Rationale for inf([0,...]) = -0. #73

Closed Chris00 closed 2 years ago

Chris00 commented 2 years ago

May you explain the rationale for inf to return -0. when the lower bound is 0.? That breaks the invariant one may expect: interval!(x.inf(), x.sup()) == x (when the interval is not empty).

unageek commented 2 years ago

Hi! This is the behavior defined by IEEE Std 1788-2015. In 12.12.8, it says:

In formats that have a signed zero, a Level 1 value of 0 shall be returned as −0 by inf, and +0 by all other functions in this subclause.


That breaks the invariant one may expect: interval!(x.inf(), x.sup()) == x (when the interval is not empty).

I don't understand this point. Could you give me an example?

Chris00 commented 2 years ago

Hi! This is the behavior defined by IEEE Std 1788-2015. In 12.12.8, it says:

Oh, I missed that point when searching in the standard.

Maybe the comment The exact value is returned. should be slightly more explicit (it all depends on how one interprets “exact” 😀).

I don't understand this point. Could you give me an example?

I naively thought that some operations would depend on the bound being +0 or -0 but it seems I was wrong.