Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAN correctness of interval multiplication #248

Open
mkeeter opened this issue Feb 14, 2025 · 4 comments
Open

NAN correctness of interval multiplication #248

mkeeter opened this issue Feb 14, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@mkeeter
Copy link
Owner

mkeeter commented Feb 14, 2025

If an interval containing 0 is multiplied by an interval that contains ±infinity, the result should be the NaN interval (because 0*inf = NaN).

@mkeeter mkeeter added the bug Something isn't working label Feb 14, 2025
@mkeeter mkeeter self-assigned this Feb 14, 2025
@Wulfsta
Copy link
Contributor

Wulfsta commented Feb 18, 2025

Is this strictly "contains zero", or is it only when 0 and ±inf end up at the same end of the interval? That is, (0, 1) * (-inf, 1) would be an issue, but (0, 1) * (1, inf) does not present a problem? I am asking partially for my own knowledge, since I am not sure if "multiplication" in this context simply produces another interval or is actually some other construct (but I am obviously assuming the former).

@mkeeter
Copy link
Owner Author

mkeeter commented Feb 18, 2025

I think it should be an "interval contains zero" check.

If any pair of values in the input intervals could produce NaN, then the output interval must be (NaN, NaN); the semantics of a (NaN, NaN) interval are "could be any value, including NaN" (and non-NaN interval must not contain NaN).

For example, (0, 1) * (1, inf) can produce NaN at the 0 * inf corner, so it should return NaN.

This example is handled correctly today, but (-1, 1) * (1, inf) is not handled correctly.

@Wulfsta
Copy link
Contributor

Wulfsta commented Feb 18, 2025

Ah, so then this does not produce another interval, but a domain of some other shape?

@mkeeter
Copy link
Owner Author

mkeeter commented Feb 18, 2025

I'm not sure what you mean by "domain", but you can think of it as modeling

enum Interval {
    Valid { lower: NonNanF32, upper: NonNanF32 },
    Invalid,
}

where Interval::Invalid is physically stored as (NaN, NaN)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants