From ad5d77f7b8101660cdf9271c00c0bfca93744d8d Mon Sep 17 00:00:00 2001 From: Lee ByeongJun Date: Thu, 26 Sep 2024 14:56:41 +0900 Subject: [PATCH] change package name --- .gitignore | 2 ++ arithmetic.go | 2 +- arithmetic_test.go | 12 +++++++++++- bits.go | 2 +- bits_errors.go | 2 +- bits_table.go | 2 +- bitwise.go | 2 +- bitwise_test.go | 2 +- cmp.go | 2 +- cmp_test.go | 2 +- coversion.go | 2 +- coversion_test.go | 2 +- errors.go | 2 +- go.mod | 5 +++++ go.sum | 4 ++++ mod.go | 2 +- runtest.go | 2 +- strconv.go | 2 +- u256.go | 2 +- u256_test.go | 2 +- utils.go | 2 +- 21 files changed, 39 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 3b735ec..4419889 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ # Go workspace file go.work + +int256 \ No newline at end of file diff --git a/arithmetic.go b/arithmetic.go index 7c9cf2c..c3e2ed8 100644 --- a/arithmetic.go +++ b/arithmetic.go @@ -2,7 +2,7 @@ // This includes basic binary operations such as addition, subtraction, multiplication, division, and modulo operations // as well as overflow checks, and negation. These functions are essential for numeric // calculations using 256-bit unsigned integers. -package u256 +package uint256 import ( "math/bits" diff --git a/arithmetic_test.go b/arithmetic_test.go index ca0e45e..24d7437 100644 --- a/arithmetic_test.go +++ b/arithmetic_test.go @@ -1,4 +1,4 @@ -package u256 +package uint256 import "testing" @@ -153,6 +153,16 @@ func TestDiv(t *testing.T) { } } +func BenchmarkDiv(b *testing.B) { + x := MustFromDecimal("31337") + y := MustFromDecimal("3") + z := &Uint{} + b.ResetTimer() + for i := 0; i < b.N; i++ { + z.Div(x, y) + } +} + func TestMod(t *testing.T) { tests := []binOp2Test{ {"31337", "3", "2"}, diff --git a/bits.go b/bits.go index 4fc7670..036044f 100644 --- a/bits.go +++ b/bits.go @@ -12,7 +12,7 @@ // the code in this package will not be used. Which // functions are implemented by the compiler depends on the // architecture and the Go release. -package u256 +package uint256 // const uintSize = 32 << (^uint(0) >> 63) // 32 or 64 diff --git a/bits_errors.go b/bits_errors.go index ad2a847..0e7eaec 100644 --- a/bits_errors.go +++ b/bits_errors.go @@ -4,7 +4,7 @@ //go:build !compiler_bootstrap -package u256 +package uint256 import ( "errors" diff --git a/bits_table.go b/bits_table.go index 98eeeb1..53dbea9 100644 --- a/bits_table.go +++ b/bits_table.go @@ -4,7 +4,7 @@ // Code generated by go run make_tables.go. DO NOT EDIT. -package u256 +package uint256 const ntz8tab = "" + "\x08\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + diff --git a/bitwise.go b/bitwise.go index 746d4a8..fc6e098 100644 --- a/bitwise.go +++ b/bitwise.go @@ -1,7 +1,7 @@ // bitwise contains bitwise operations for Uint instances. // This file includes functions to perform bitwise AND, OR, XOR, and NOT operations, as well as bit shifting. // These operations are crucial for manipulating individual bits within a 256-bit unsigned integer. -package u256 +package uint256 // Or sets z = x | y and returns z. func (z *Uint) Or(x, y *Uint) *Uint { diff --git a/bitwise_test.go b/bitwise_test.go index e94d5fb..aba89ed 100644 --- a/bitwise_test.go +++ b/bitwise_test.go @@ -1,4 +1,4 @@ -package u256 +package uint256 import "testing" diff --git a/cmp.go b/cmp.go index dc309fb..a43a31e 100644 --- a/cmp.go +++ b/cmp.go @@ -2,7 +2,7 @@ // These comparison functions cover a range of operations including equality checks, less than/greater than // evaluations, and specialized comparisons such as signed greater than. These are fundamental for logical // decision making based on Uint values. -package u256 +package uint256 import ( "math/bits" diff --git a/cmp_test.go b/cmp_test.go index e54b223..d108caf 100644 --- a/cmp_test.go +++ b/cmp_test.go @@ -1,4 +1,4 @@ -package u256 +package uint256 import ( "strings" diff --git a/coversion.go b/coversion.go index 26b4b6c..4ef9060 100644 --- a/coversion.go +++ b/coversion.go @@ -1,7 +1,7 @@ // conversions contains methods for converting Uint instances to other types and vice versa. // This includes conversions to and from basic types such as uint64 and int32, as well as string representations // and byte slices. Additionally, it covers marshaling and unmarshaling for JSON and other text formats. -package u256 +package uint256 import ( "encoding/binary" diff --git a/coversion_test.go b/coversion_test.go index b619b1d..ee3aad0 100644 --- a/coversion_test.go +++ b/coversion_test.go @@ -1,4 +1,4 @@ -package u256 +package uint256 import "testing" diff --git a/errors.go b/errors.go index 61d6328..2f54d0e 100644 --- a/errors.go +++ b/errors.go @@ -1,4 +1,4 @@ -package u256 +package uint256 import ( "errors" diff --git a/go.mod b/go.mod index 6490d17..b0b9415 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,8 @@ module github.com/gnoswap-labs/uint256 go 1.21.6 + +require ( + github.com/holiman/uint256 v1.2.2 // indirect + github.com/linhbkhn95/int256 v0.0.3 // indirect +) diff --git a/go.sum b/go.sum index e69de29..2aa66fc 100644 --- a/go.sum +++ b/go.sum @@ -0,0 +1,4 @@ +github.com/holiman/uint256 v1.2.2 h1:TXKcSGc2WaxPD2+bmzAsVthL4+pEN0YwXcL5qED83vk= +github.com/holiman/uint256 v1.2.2/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= +github.com/linhbkhn95/int256 v0.0.3 h1:krzOksQaUEiJh3YTZGFNAmH9U06rp5qXjjEjAYhVRxk= +github.com/linhbkhn95/int256 v0.0.3/go.mod h1:Diyo8xxncRVZJbuMOJENeYOloCZPO1uLALyd23ZPkiY= diff --git a/mod.go b/mod.go index a6bd3c8..f6ff096 100644 --- a/mod.go +++ b/mod.go @@ -1,4 +1,4 @@ -package u256 +package uint256 import ( "math/bits" diff --git a/runtest.go b/runtest.go index 96e3284..8bb27a5 100644 --- a/runtest.go +++ b/runtest.go @@ -1,4 +1,4 @@ -package u256 +package uint256 func Hello() uint64 { x := NewUint(1) diff --git a/strconv.go b/strconv.go index e448576..c149613 100644 --- a/strconv.go +++ b/strconv.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package u256 +package uint256 const fastSmalls = true // enable fast path for small integers diff --git a/u256.go b/u256.go index f33ccb4..80da0ba 100644 --- a/u256.go +++ b/u256.go @@ -1,6 +1,6 @@ // Ported from https://github.com/holiman/uint256 // This package provides a 256-bit unsigned integer type, Uint256, and associated functions. -package u256 +package uint256 import ( "errors" diff --git a/u256_test.go b/u256_test.go index 302faff..e1bf49d 100644 --- a/u256_test.go +++ b/u256_test.go @@ -1,4 +1,4 @@ -package u256 +package uint256 import ( "testing" diff --git a/utils.go b/utils.go index de0b384..969728f 100644 --- a/utils.go +++ b/utils.go @@ -1,4 +1,4 @@ -package u256 +package uint256 // lower(c) is a lower-case letter if and only if // c is either that lower-case letter or the equivalent upper-case letter.