Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: holiman/uint256
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2.2
Choose a base ref
...
head repository: holiman/uint256
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.2.3
Choose a head ref
  • 5 commits
  • 7 files changed
  • 2 contributors

Commits on Mar 24, 2023

  1. implement Float64() conversion (#132)

    Float64 returns the float64 value nearest to x.
    
        func (z *Int) Float64() float64
    
    goos: linux
    goarch: amd64
    pkg: github.com/holiman/uint256
    cpu: 12th Gen Intel(R) Core(TM) i7-1270P
    BenchmarkFloat64/Float64/uint256-8                246834              4681 ns/op               0 B/op          0 allocs/op
    BenchmarkFloat64/Float64/uint256-8                564375              4651 ns/op               0 B/op          0 allocs/op
    BenchmarkFloat64/Float64/uint256-8                256735              4545 ns/op               0 B/op          0 allocs/op
    BenchmarkFloat64/Float64/uint256-8                567476              2117 ns/op               0 B/op          0 allocs/op
    BenchmarkFloat64/Float64/uint256-8                562767              2114 ns/op               0 B/op          0 allocs/op
    BenchmarkFloat64/Float64/big-8                     23724             55516 ns/op           23424 B/op        510 allocs/op
    BenchmarkFloat64/Float64/big-8                     18283             64730 ns/op           23424 B/op        510 allocs/op
    BenchmarkFloat64/Float64/big-8                     18610             60523 ns/op           23424 B/op        510 allocs/op
    BenchmarkFloat64/Float64/big-8                     19528             62700 ns/op           23424 B/op        510 allocs/op
    BenchmarkFloat64/Float64/big-8                     19828             56352 ns/op           23424 B/op        510 allocs/op
    holiman authored Mar 24, 2023
    Configuration menu
    Copy the full SHA
    b82def6 View commit details
    Browse the repository at this point in the history

Commits on Mar 27, 2023

  1. tests: naming conventions for benchmarks, remove obsolete (#133)

    * tests: naming conventions for benchmarks, remove obsolete
    
    * updated benchmarks
    holiman authored Mar 27, 2023
    Configuration menu
    Copy the full SHA
    71f8c05 View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2023

  1. ToBig, FromBig, MustFromBig: allow conversion of nil-values (#137)

    In some places, having a `nil` as a `big.Int` or `uint256.Int` might make sense (e.g. an optional and non-initialized field). In those cases, converting between the two across older/newer code might be necessary.
    
    This changes makes it so `ToBig`, `FromBig` and `MustFromBig` do not crash, but rather just returns `nil` in case the input-to-convert is `nil`.
    ---------
    
    Co-authored-by: Martin Holst Swende <martin@swende.se>
    karalabe and holiman authored Mar 31, 2023
    Configuration menu
    Copy the full SHA
    c46f3b8 View commit details
    Browse the repository at this point in the history
  2. Implement CmpBig (#138)

    Implements `CmpBig`
    
    	// CmpBig compares z and x and returns:
    	//
    	//	-1 if z <  x
    	//	 0 if z == x
    	//	+1 if z >  x
    	func (z *Int) CmpBig(x *big.Int) (r int)
    holiman authored Mar 31, 2023
    Configuration menu
    Copy the full SHA
    1c9ad56 View commit details
    Browse the repository at this point in the history
  3. implement Log10 and CmpUint64 (#136)

    Adds the following methods
    
    ```golang
    // CmpUint64 compares z and x and returns:
    //
    //	-1 if z <  x
    //	 0 if z == x
    //	+1 if z >  x
    func (z *Int) CmpUint64(n uint64) int 
    
    // Log10 returns the log in base 10, floored to nearest integer.
    // **OBS** This method returns '0' for '0', not `-Inf`.
    func (z *Int) Log10() uint
    ```
    The implementation of `Log10` is probably close to the optimal way. The majority of cases are handled by one lookup based on the bitlength. 
    
    For the remaining cases, one an additional lookup is performed, a comparison, and then it is done. 
    
    This PR adds around 2K persistent memory for lookup tables and precalculated integers. 
    ```
    lut [257] uint8 // 257 B
    pows = [60]Int         // 1920 B 
    pows64 = [20]uint64 // 20*8 = 160 B
    ```
    
    Ref: #123
    holiman authored Mar 31, 2023
    2 Configuration menu
    Copy the full SHA
    e42b95a View commit details
    Browse the repository at this point in the history
Loading