tag:blogger.com,1999:blog-14415229.post7530647377431461530..comments2023-10-10T16:55:02.139+02:00Comments on Chase The Devil: Java int Overflow BehaviorFabienhttp://www.blogger.com/profile/07288327695801480778noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-14415229.post-58391954469147088092011-12-09T01:00:50.696+01:002011-12-09T01:00:50.696+01:00Actually, the specification is clear about it:If a...Actually, the specification <i>is</i> clear about it:<br><br><a href="http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#13510" rel="nofollow">If an integer addition overflows, then the result is the low-order bits of the mathematical sum as represented in some sufficiently large two's-complement format.</a>Danielhttps://www.blogger.com/profile/07505997833685327219noreply@blogger.comtag:blogger.com,1999:blog-14415229.post-11004781136912579712009-06-18T10:26:09.981+02:002009-06-18T10:26:09.981+02:00See the binarySearch() methods in the Arrays and C...See the binarySearch() methods in the Arrays and Collections classes... it handles a possible overflow due to the addition of two ints by an unsigned right shift...Trollhornnoreply@blogger.comtag:blogger.com,1999:blog-14415229.post-80662242273696308932009-06-17T20:31:21.059+02:002009-06-17T20:31:21.059+02:00Its part of the TCK tests. These are the tests a ...Its part of the TCK tests. These are the tests a JVM must pass in order to be a compliant Java VM. So the answer is yes this will be true on all compliant JVMs.Eric Arseneauhttps://www.blogger.com/profile/01201512975888985121noreply@blogger.com