From a2e8b18126ce0362add8202c26cd27f2588f77b2 Mon Sep 17 00:00:00 2001 From: nicksavers Date: Mon, 20 Oct 2014 12:39:14 +0200 Subject: [PATCH] Fix DataWord compareTo in convention with Comparable interface --- ethereumj-core/src/main/java/org/ethereum/vm/DataWord.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/DataWord.java b/ethereumj-core/src/main/java/org/ethereum/vm/DataWord.java index ab2ad40d..c06eab38 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/DataWord.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/DataWord.java @@ -282,9 +282,10 @@ public class DataWord implements Comparable { @Override public int compareTo(DataWord o) { if (o == null || o.getData() == null) return -1; - - return FastByteComparisons.compareTo( + int result = FastByteComparisons.compareTo( data, 0, data.length, o.getData(), 0, o.getData().length); + // Convert result into -1, 0 or 1 as is the convention + return (int) Math.signum(result); } } \ No newline at end of file