File tree Expand file tree Collapse file tree
src/main/java/de/tilman_neumann/jml/base Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828 *
2929 * @author Tilman Neumann
3030 */
31- public class Int128 {
31+ public class Int128 implements Comparable < Int128 > {
3232 @ SuppressWarnings ("unused" )
3333 private static final Logger LOG = LogManager .getLogger (Int128 .class );
3434
@@ -49,6 +49,26 @@ public long getLow() {
4949 return low ;
5050 }
5151
52+ @ Override
53+ public int compareTo (Int128 b ) {
54+ return high != b .high ? Long .compareUnsigned (high , b .high ) : Long .compareUnsigned (low , b .low );
55+ }
56+
57+ @ Override
58+ public boolean equals (Object o ) {
59+ if (o instanceof Int128 ) {
60+ Int128 b = (Int128 ) o ;
61+ return high == b .high && low == b .low ;
62+ }
63+ // we could treat other number classes here like Long but this is sufficient for a start
64+ return false ;
65+ }
66+
67+ @ Override
68+ public int hashCode () {
69+ return Long .hashCode (high ) * 31 + Long .hashCode (low );
70+ }
71+
5272 /**
5373 * Add two 128 bit integers.
5474 * @param b
You can’t perform that action at this time.
0 commit comments