From e02c0fa8088943bc995d290e58a7226f4a0ece91 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 10 Oct 2014 17:00:06 +0200 Subject: Added generic big to 256 method. Implemented new iterator --- ethutil/big.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ethutil/big.go') diff --git a/ethutil/big.go b/ethutil/big.go index d8f54ad10..e23d8f659 100644 --- a/ethutil/big.go +++ b/ethutil/big.go @@ -39,12 +39,14 @@ func BigD(data []byte) *big.Int { // "cast" the big int to a 256 big int (i.e., limit to) var tt256 = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1)) -func To256(x *big.Int) { +func To256(x *big.Int) *big.Int { x.And(x, tt256) if x.Cmp(new(big.Int)) < 0 { x.SetInt64(0) } + + return x } // Big to bytes -- cgit v1.2.3