Skip to content

Commit

Permalink
FIX interval_algebra::Ne method
Browse files Browse the repository at this point in the history
  • Loading branch information
orlarey committed Mar 5, 2024
1 parent 0b2b40a commit 0b42e8b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions interval/intervalNe.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* Copyright 2023 Yann ORLAREY
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -34,16 +34,16 @@ interval interval_algebra::Ne(const interval& x, const interval& y) const
if ((x.hi() < y.lo()) || x.lo() > y.hi()) {
return interval{1.0};
}
if ((x.hi() == y.lo()) || x.lo() == y.hi()) {
if ((x.hi() == y.lo()) && x.lo() == y.hi()) {
return interval{0.0};
}
return {0, 1};
}

void interval_algebra::testNe() const
{
check("test algebra Ne", Ne(interval(0, 5), interval(-3, 10)), interval(0, 1));
check("test algebra Ne", Ne(interval(0, 5), interval(5, 10)), interval(0, 1));
check("test algebra Ne", Ne(interval(0, 5), interval(8, 10)), interval(1));
check("test algebra Ne", Ne(interval(0, 0), interval(0, 0)), interval(0));
check("test algebra Ne", Ne(interval(1, 1), interval(1, 1)), interval(0, 0));
}
} // namespace itv

1 comment on commit 0b42e8b

@sletz
Copy link
Member

@sletz sletz commented on 0b42e8b Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.