From dd45965240cc4347c6490146576db2558c0572cc Mon Sep 17 00:00:00 2001 From: nicksavers Date: Thu, 22 May 2014 10:42:56 +0200 Subject: [PATCH 1/2] Nicer code to calculate power of --- .../src/main/java/org/ethereum/core/Denomination.java | 5 ++--- ethereumj-core/src/main/java/org/ethereum/core/Genesis.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java b/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java index b895b8cf..e8c8e418 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java @@ -1,6 +1,5 @@ package org.ethereum.core; -import java.math.BigDecimal; import java.math.BigInteger; public enum Denomination { @@ -23,7 +22,7 @@ public enum Denomination { return amount; } - private static BigInteger newBigInt(double value) { - return BigDecimal.valueOf(Math.pow(10, value)).toBigInteger(); + private static BigInteger newBigInt(int value) { + return BigInteger.valueOf(2).pow(value); } } diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java b/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java index 54b00d83..ad217e99 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java @@ -18,7 +18,7 @@ public class Genesis extends Block { private static byte[] stateRoot = // TODO: Get stateRoot from actual state Hex.decode("12582945fc5ad12c3e7b67c4fc37a68fc0d52d995bb7f7291ff41a2739a7ca16"); private static byte[] txTrieRoot = new byte[0]; - private static byte[] difficulty = BigInteger.valueOf((long) Math.pow(2, 22)).toByteArray(); + private static byte[] difficulty = BigInteger.valueOf(2).pow(22).toByteArray(); private static long number = 0; private static long minGasPrice = 0; private static long gasLimit = 1000000; From c34714cbe8a03e706f90fae3708a7466781d6c70 Mon Sep 17 00:00:00 2001 From: Nick Savers Date: Thu, 22 May 2014 10:49:10 +0200 Subject: [PATCH 2/2] Fix denom base --- .../src/main/java/org/ethereum/core/Denomination.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java b/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java index e8c8e418..8e2b6b97 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java @@ -23,6 +23,6 @@ public enum Denomination { } private static BigInteger newBigInt(int value) { - return BigInteger.valueOf(2).pow(value); + return BigInteger.valueOf(10).pow(value); } }