Skip to content

Commit ebeb0ff

Browse files
committed
fix: abs works with WHOLE interval (fixes #26)
1 parent e49d3f8 commit ebeb0ff

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/operations/misc.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ describe('Interval', function () {
123123
Interval.almostEqual(n, [2, 3])
124124
n = Interval.abs(new Interval(2, 3))
125125
Interval.almostEqual(n, [2, 3])
126+
n = Interval.abs(Interval.WHOLE)
127+
Interval.almostEqual(n, Interval.EMPTY)
126128
})
127129

128130
it('should compute the max value of two intervals', function () {

src/operations/misc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export const wid = width
309309
* @return {Interval}
310310
*/
311311
export function abs(x: Interval): Interval {
312-
if (utils.isEmpty(x)) {
312+
if (utils.isEmpty(x) || utils.isWhole(x)) {
313313
return constants.EMPTY
314314
}
315315
if (x.lo >= 0) {

0 commit comments

Comments
 (0)