forked from java2script/java2script
-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Description
The inequality test methods $le, $lt, $ge, $gt for Long type return incorrect answers for negative longs using array notation.
Example 1 - comparing two "large" longs:
long a = -30000000000000000L;
long b = -70000000000000000L;
assert a > b;
assert a >= b;
assert b < a;
assert b <= a;Example 2 - comparing "large" long with "small" long:
long a = -1;
long b = -(1L << 54);
assert a > b;
assert a >= b;
assert b < a;
assert b <= a;Example 3 - comparing two "small" longs:
long a = Long.parseLong("-1");
long b = Long.parseLong("-2");
assert a > b;
assert a >= b;
assert b < a;
assert b <= a;All assertions in the examples above fail.
I think the problem is the implementation of the inequality comparisons which compare a[1] to b[1] and then a[0] to b[0] with no regard to signs of the numbers a[2], b[2].
I suggest fixing the $cmp method and then making all other comparisons rely on this one.
Metadata
Metadata
Assignees
Labels
No labels