diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-04-10 00:12:44 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-04-10 00:12:44 +0000 |
commit | 50238129f1393f9b7087669984f6300b16c740e3 (patch) | |
tree | d7932cc4beff5fcbf1c3297e505bb3c51064ee03 /src | |
parent | 653d6ee1fc4ffe7e60487a401298832faac18b48 (diff) |
Strongly typed minus throws too often [issue 101], patch from olov.lassus
Diffstat (limited to 'src')
-rw-r--r-- | src/jvm/clojure/lang/Numbers.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/jvm/clojure/lang/Numbers.java b/src/jvm/clojure/lang/Numbers.java index d67a4aa1..cf7f4042 100644 --- a/src/jvm/clojure/lang/Numbers.java +++ b/src/jvm/clojure/lang/Numbers.java @@ -1734,7 +1734,7 @@ static public int xor(int x, int y){ static public int minus(int x, int y){ int ret = x - y; - if (((ret ^ x) < 0 && (ret ^ -y) < 0) || (y == Integer.MIN_VALUE)) + if (((ret ^ x) < 0 && (ret ^ ~y) < 0)) return throwIntOverflow(); return ret; } @@ -1841,13 +1841,13 @@ static public long add(long x, long y){ static public long minus(long x, long y){ long ret = x - y; - if (((ret ^ x) < 0 && (ret ^ -y) < 0) || (y == Long.MIN_VALUE)) + if (((ret ^ x) < 0 && (ret ^ ~y) < 0)) return throwIntOverflow(); return ret; } static public long minus(long x){ - if(x == Integer.MIN_VALUE) + if(x == Long.MIN_VALUE) return throwIntOverflow(); return -x; } |