Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uint256: Introduce package. #2787

Merged
merged 59 commits into from
Nov 20, 2021
Merged

uint256: Introduce package. #2787

merged 59 commits into from
Nov 20, 2021

Commits on Nov 19, 2021

  1. uint256: Introduce package infrastructure.

    Profiling the CPU usage during an initial chain sync shows that roughly
    65-70% of all time is spent in garbage collection operations.  This is
    primarily the result of a large number of in-use allocations.  Profiling
    the in-use allocations shows that around almost a quarter of all in-use
    allocations (~22%) are due to standard library big integers which
    require allocations.  In other words, eliminating those allocations
    should lead to a speedup of around 10% to the initial chain sync.
    
    More specifically, the allocations in question are the result of several
    important calculations which could be done without allocations, and more
    efficiently in terms of execution time, via fixed precision unsigned
    256-bit integers.
    
    Thus, motivated by the previous discussion, this is part of a series of
    commits that implements highly optimized allocation free fixed precision
    unsigned 256-bit integer arithmetic that can ultimately be used in place
    of the standard library big integers.
    
    For the time being, the package is introduced into the internal staging
    area for initial review.
    
    The following is a brief overview of the main features and benefits:
    
    - Strong focus on performance and correctness
    - Every operation is faster than the stdlib big.Int equivalent and most
      operations, including the primary math operations, are significantly
      faster
    - Allocation free
      - All non-formatting operations with the specialized type are allocation free
    - Supports boolean comparison, bitwise logic, and bitwise shift operations
    - All operations are performed modulo 2^256
    - Ergonomic API with unary-style arguments as well as some binary variants
    - Conversion-free support for interoperation with native uint64 integers
    - Direct conversion to and from little and big endian byte arrays
    - Full support for formatted output and common base conversions
      - Formatted output uses fewer allocations than stdlib big.Int
    - 100% test coverage
    - Comprehensive benchmarks
    
    In order to help ease the review process, the full implementation will
    be done across many commits.
    
    This commit only contains the basic type definition and ability to set
    it to a uint64 or another uint256 along with tests, so it is not very
    useful on its own.
    
    Future commits will implement support for interpreting and producing big
    and little endian bytes, the primary arithmetic operations (addition,
    subtraction, multiplication, squaring, division, negation), bitwise
    operations (lsh, rsh, not, or, and, xor), comparison operations (equals,
    less, greater, cmp), and other convenience methods such as determining
    the minimum number of bits required to represent the current value,
    whether or not the value can be represented as a uint64 without loss of
    precision, and text formatting with base conversion.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    97526bd View commit details
    Browse the repository at this point in the history
  2. uint256: Add set from big endian bytes.

    This adds the ability for the uint256 to be set by interpreting arrays
    and slices as a 256-bit big-endian integer and associated tests to
    ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    6beb1b3 View commit details
    Browse the repository at this point in the history
  3. uint256: Add big endian set benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name       old time/op    new time/op    delta
    ------------------------------------------------------------------
    SetBytes   9.09ns ±13%    3.05ns ± 1%   -66.43%  (p=0.000 n=10+10)
    
    name       old allocs/op  new allocs/op  delta
    ----------------------------------------------------------
    SetBytes   0.00           0.00           ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    e785c25 View commit details
    Browse the repository at this point in the history
  4. uint256: Add set from little endian bytes.

    This adds the ability for the uint256 to be set by interpreting arrays
    and slices as a 256-bit little-endian integer and associated tests to
    ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    2bec2b5 View commit details
    Browse the repository at this point in the history
  5. uint256: Add little endian set benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name         old time/op     new time/op     delta
    -----------------------------------------------------------------------
    SetBytesLE   59.9ns ± 4%     3.1ns ± 2%      -94.76%  (p=0.000 n=10+10)
    
    name         old allocs/op   new allocs/op   delta
    ------------------------------------------------------------------------
    SetBytesLE   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    d838d58 View commit details
    Browse the repository at this point in the history
  6. uint256: Add get big endian bytes.

    This adds the ability for the uint256 to unpack its value to arrays and
    slices as a 256-bit big-endian integer and associated tests to ensure
    proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    7fbfaac View commit details
    Browse the repository at this point in the history
  7. uint256: Add big endian get benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name    old time/op     new time/op     delta
    ------------------------------------------------------------------
    Bytes   61.3ns ± 1%     13.8ns ± 3%     -77.49%  (p=0.000 n=10+10)
    
    name    old allocs/op   new allocs/op   delta
    -------------------------------------------------------------------
    Bytes   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    aafccab View commit details
    Browse the repository at this point in the history
  8. uint256: Add get little endian bytes.

    This adds the ability for the uint256 to unpack its value to arrays and
    slices as a 256-bit little-endian integer and associated tests to ensure
    proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    466ebf9 View commit details
    Browse the repository at this point in the history
  9. uint256: Add little endian get benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name      old time/op     new time/op     delta
    --------------------------------------------------------------------
    BytesLE   83.5ns ± 2%     13.9ns ± 2%     -83.32%  (p=0.000 n=10+10)
    
    name      old allocs/op   new allocs/op   delta
    ---------------------------------------------------------------------
    BytesLE   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    2f2d347 View commit details
    Browse the repository at this point in the history
  10. uint256: Add zero support.

    This adds the ability to zero an existing uint256 and determine if it is
    zero along with associated tests to ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    8952fc5 View commit details
    Browse the repository at this point in the history
  11. uint256: Add zero benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name     old time/op     new time/op     delta
    -------------------------------------------------------------------
    Zero     2.99ns ± 2%     1.29ns ± 1%     -56.82%  (p=0.000 n=10+10)
    IsZero   1.78ns ± 0%     1.63ns ± 2%      -8.23%  (p=0.000 n=10+10)
    
    name     old allocs/op   new allocs/op   delta
    ----------------------------------------------------------
    Zero     0.00            0.00            ~     (all equal)
    IsZero   0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    99f214c View commit details
    Browse the repository at this point in the history
  12. uint256: Add uint32 casting support.

    This adds the ability to determine if a uint256 can be converted to a
    uint32 without any loss of precision as well a method to cast it along
    with associated tests to ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    90315bf View commit details
    Browse the repository at this point in the history
  13. uint256: Add uint64 casting support.

    This adds the ability to determine if a uint256 can be converted to a
    uint64 without any loss of precision as well a method to cast it along
    with associated tests to ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    b46ff5e View commit details
    Browse the repository at this point in the history
  14. uint256: Add equality comparison support.

    This adds the ability to determine if a uint256 represents the same
    value as another uint256 or as a uint64 along with associated tests to
    ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    ed6ef23 View commit details
    Browse the repository at this point in the history
  15. uint256: Add equality comparison benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name   old time/op     new time/op     delta
    -----------------------------------------------------------------
    Eq     12.7ns ± 1%     2.1ns ± 1%      -83.72%  (p=0.000 n=10+10)
    
    name   old allocs/op   new allocs/op   delta
    --------------------------------------------------------
    Eq     0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    393c7d6 View commit details
    Browse the repository at this point in the history
  16. uint256: Add less than comparison support.

    This adds the ability to determine if a uint256 is less than another
    uint256 or a uint64 along with associated tests to ensure proper
    functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    e574a5f View commit details
    Browse the repository at this point in the history
  17. uint256: Add less than comparison benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name   old time/op     new time/op     delta
    -----------------------------------------------------------------
    Lt     12.6ns ± 1%     3.0ns ± 1%      -75.96%  (p=0.000 n=10+10)
    
    name   old allocs/op   new allocs/op   delta
    --------------------------------------------------------
    Lt     0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    7e9ed05 View commit details
    Browse the repository at this point in the history
  18. uint256: Add less or equals comparison support.

    This adds the ability to determine if a uint256 is less than or equal to
    another uint256 or a uint64 along with associated tests to ensure proper
    functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    4831b21 View commit details
    Browse the repository at this point in the history
  19. uint256: Add greater than comparison support.

    This adds the ability to determine if a uint256 is greater than another
    uint256 or a uint64 along with associated tests to ensure proper
    functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    c1b94c2 View commit details
    Browse the repository at this point in the history
  20. uint256: Add greater than comparison benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name   old time/op     new time/op     delta
    -----------------------------------------------------------------
    Gt     12.6ns ± 1%     3.0ns ± 1%      -75.91%  (p=0.000 n=10+10)
    
    name   old allocs/op   new allocs/op   delta
    --------------------------------------------------------
    Gt     0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    dd40c57 View commit details
    Browse the repository at this point in the history
  21. uint256: Add greater or equals comparison support.

    This adds the ability to determine if a uint256 is greater than or equal
    to another uint256 or a uint64 along with associated tests to ensure
    proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    e8ba80e View commit details
    Browse the repository at this point in the history
  22. uint256: Add general comparison support.

    This adds the ability to compare a uint256 to another uint256 or a
    uint64 along with associated tests to ensure proper functionality.
    
    The comparison logic is the usual logic where -1 is returned when the
    uint256 is less than the value being compared to, 0 when it is equal,
    and 1 when it is greater.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    2d86902 View commit details
    Browse the repository at this point in the history
  23. uint256: Add general comparison benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name        old time/op     new time/op     delta
    ----------------------------------------------------------------------
    Cmp         12.6ns  ± 1%    7.7ns ± 1%      -39.01%  (p=0.000 n=10+10)
    CmpUint64    5.93ns ± 2%    3.7ns ± 1%      -37.60%  (p=0.000 n=10+10)
    
    name        old allocs/op   new allocs/op   delta
    -------------------------------------------------------------
    Cmp         0.00            0.00            ~     (all equal)
    CmpUint64   0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    5b08928 View commit details
    Browse the repository at this point in the history
  24. uint256: Add addition support.

    This adds support for uint256 addition (modulo 2^256) along with
    associated tests to ensure proper functionality.
    
    It includes adding a uint256 to an existing one (a += b), adding two
    uint256s and assigning the result to a third (a = b + c), and adding a
    uint64 to an existing uint256 (a += uint256(b)).
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    ff8c41c View commit details
    Browse the repository at this point in the history
  25. uint256: Add addition benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name        old time/op     new time/op     delta
    ----------------------------------------------------------------------
    Add         158.0ns ± 2%    2.0ns ± 1%      -98.67%  (p=0.000 n=10+10)
    AddUint64    44.4ns ± 3%    3.4ns ± 2%      -92.27%  (p=0.000 n=10+10)
    
    name        old allocs/op   new allocs/op   delta
    -------------------------------------------------------------
    Add         0.00            0.00            ~     (all equal)
    AddUint64   0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    e6b423b View commit details
    Browse the repository at this point in the history
  26. uint256: Add subtraction support.

    This adds support for uint256 subtraction (modulo 2^256) along with
    associated tests to ensure proper functionality.
    
    It includes subtracting a uint256 from an existing one (a -= b),
    subtracting two uint256s and assigning the result to a third (a = b -
    c), and subtracting a uint64 from an existing uint256 (a -= uint256(b)).
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    90d4ba8 View commit details
    Browse the repository at this point in the history
  27. uint256: Add subtraction benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name        old time/op     new time/op     delta
    ---------------------------------------------------------------------
    Sub         53.9ns ± 1%    2.1ns ± 1%      -96.12%  (p=0.000 n=10+10)
    SubUint64   44.8ns ± 1%    3.4ns ± 2%      -92.37%  (p=0.000 n=10+10)
    
    name        old allocs/op   new allocs/op   delta
    -------------------------------------------------------------
    Sub         0.00            0.00            ~     (all equal)
    SubUint64   0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    fe684af View commit details
    Browse the repository at this point in the history
  28. uint256: Add multiplication support.

    This adds support for uint256 multiplication (modulo 2^256) along with
    associated tests to ensure proper functionality.
    
    It includes multiplying a uint256 with an existing one (a *= b),
    multiplying two uint256s and assigning the result to a third (a = b *
    c), and multiplying an existing uint256 with a uint64 (a *= uint256(b)).
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    8cfc4dc View commit details
    Browse the repository at this point in the history
  29. uint256: Add multiplication benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name        old time/op     new time/op     delta
    ----------------------------------------------------------------------
    Mul         419ns ± 1%      10ns ± 1%      -97.64%  (p=0.000 n=10+10)
    MulUint64   263ns ± 1%       4ns ± 1%      -98.30%  (p=0.000 n=10+10)
    
    name        old allocs/op   new allocs/op   delta
    -----------------------------------------------------------------------
    Mul         1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    MulUint64   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    fa9f70e View commit details
    Browse the repository at this point in the history
  30. uint256: Add squaring support.

    This adds support for uint256 squaring (modulo 2^256) along with
    associated tests to ensure proper functionality.
    
    It includes squaring an existing uint256 (a *= a) and assigning the
    result of squaring a uint256 to a second one (a = b*b).
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    dc2a08f View commit details
    Browse the repository at this point in the history
  31. uint256: Add squaring benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name     old time/op     new time/op     delta
    -------------------------------------------------------------------
    Square   418ns ± 0%      7ns ± 2%        -98.39%  (p=0.000 n=10+10)
    
    name     old allocs/op   new allocs/op   delta
    --------------------------------------------------------------------
    Square   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    8d27f65 View commit details
    Browse the repository at this point in the history
  32. uint256: Add division support.

    This adds support for uint256 division (modulo 2^256) along with
    associated tests to ensure proper functionality.
    
    It includes dividing an existing uint256 by a second one (a /= b),
    dividing two uint256s and assigning the result to a third (a = b/c), and
    dividing an existing uint256 by a uint64 (a /= uint256(b)).
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    7ef9c18 View commit details
    Browse the repository at this point in the history
  33. uint256: Add division benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name              old time/op     new time/op     delta
    ----------------------------------------------------------------------------
    Div/num_lt_den     75.4ns ± 1%     3.4ns ± 1%     -95.51%  (p=0.000 n=10+10)
    Div/num_eq_den    253.0ns ± 2%     4.0ns ± 3%     -98.56%  (p=0.000 n=10+10)
    Div/1_by_1_near    53.8ns ± 2%     4.5ns ± 2%     -91.63%  (p=0.000 n=10+10)
    Div/1_by_1_far     31.4ns ± 2%    14.6ns ± 2%     -53.64%  (p=0.000 n=10+10)
    Div/2_by_1_near    36.9ns ± 1%    10.1ns ± 2%     -72.63%  (p=0.000 n=10+10)
    Div/2_by_1_far     49.1ns ± 1%    28.8ns ± 1%     -41.29%  (p=0.000 n=10+10)
    Div/3_by_1_near    43.2ns ± 1%    13.7ns ± 3%     -68.24%  (p=0.000 n=10+10)
    Div/3_by_1_far     57.0ns ± 1%    43.6ns ± 1%     -23.59%  (p=0.000 n=10+10)
    Div/4_by_1_near    49.7ns ± 4%    18.0ns ± 1%     -63.87%  (p=0.000 n=10+10)
    Div/4_by_1_far     65.2ns ± 4%    57.8ns ± 2%     -11.41%  (p=0.000 n=10+10)
    Div/2_by_2_near   237.0ns ± 1%    22.0ns ± 3%     -90.81%  (p=0.000 n=10+10)
    Div/2_by_2_far    237.0ns ± 1%    30.0ns ± 3%     -87.17%  (p=0.000 n=10+10)
    Div/3_by_2_near   258.0ns ± 1%    29.0ns ± 1%     -88.60%  (p=0.000 n=10+10)
    Div/3_by_2_far    257.0ns ± 1%    50.0ns ± 2%     -80.42%  (p=0.000 n=10+10)
    Div/4_by_2_near   312.0ns ± 2%    40.0ns ± 3%     -87.27%  (p=0.000 n=10+10)
    Div/4_by_2_far    310.0ns ± 1%    71.0ns ± 3%     -77.19%  (p=0.000 n=10+10)
    Div/3_by_3_near   239.0ns ± 2%    21.0ns ± 2%     -91.39%  (p=0.000 n=10+10)
    Div/3_by_3_far    242.0ns ± 4%    33.0ns ± 3%     -86.33%  (p=0.000 n=10+10)
    Div/4_by_3_near   279.0ns ± 6%    31.0ns ± 1%     -89.01%  (p=0.000 n=10+10)
    Div/4_by_3_far    271.0ns ± 1%    46.0ns ± 3%     -82.99%  (p=0.000 n=10+10)
    Div/4_by_4_near   252.0ns ± 3%    20.0ns ± 3%     -91.99%  (p=0.000 n=10+10)
    Div/4_by_4_far    249.0ns ± 2%    36.0ns ± 2%     -85.65%  (p=0.000 n=10+10)
    DivRandom         202.0ns ± 1%    23.0ns ± 1%     -88.43%  (p=0.000 n=10+10)
    DivUint64         129.0ns ± 1%    47.0ns ± 0%     -63.34%  (p=0.000 n=10+10)
    
    name              old allocs/op   new allocs/op   delta
    -----------------------------------------------------------------------------
    Div/num_lt_den    1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/num_eq_den    1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/1_by_1_far    0.00            0.00                ~     (all equal)
    Div/1_by_1_near   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/2_by_1_far    0.00            0.00                ~     (all equal)
    Div/2_by_1_near   0.00            0.00                ~     (all equal)
    Div/3_by_1_far    0.00            0.00                ~     (all equal)
    Div/3_by_1_near   0.00            0.00                ~     (all equal)
    Div/4_by_1_far    0.00            0.00                ~     (all equal)
    Div/4_by_1_near   0.00            0.00                ~     (all equal)
    Div/2_by_2_far    1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/2_by_2_near   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/3_by_2_far    1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/3_by_2_near   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/4_by_2_far    1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/4_by_2_near   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/3_by_3_far    1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/3_by_3_near   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/4_by_3_far    1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/4_by_3_near   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/4_by_4_far    1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    Div/4_by_4_near   1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    DivRandom         1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    DivUint64         1.00 ± 0%       0.00            -100.00%  (p=0.000 n=10+10)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    ff68ec7 View commit details
    Browse the repository at this point in the history
  34. uint256: Add negation support.

    This adds support for uint256 negation (modulo 2^256) along with
    associated tests to ensure proper functionality.
    
    It includes negating an existing uint256 (a = -a) and assigning the
    result of negating a uint256 to a second one (a = -b).
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    d92a330 View commit details
    Browse the repository at this point in the history
  35. uint256: Add negation benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name     old time/op     new time/op     delta
    -------------------------------------------------------------------
    Negate   47.3ns ± 2%     1.5ns ± 2%      -96.91%  (p=0.000 n=10+10)
    
    name     old allocs/op   new allocs/op   delta
    ----------------------------------------------------------
    Negate   0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    768cf62 View commit details
    Browse the repository at this point in the history
  36. uint256: Add is odd support.

    This adds the ability to determine if a uint256 is odd along with
    associated tests to ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    944a888 View commit details
    Browse the repository at this point in the history
  37. uint256: Add is odd benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name    old time/op     new time/op     delta
    ------------------------------------------------------------------
    IsOdd   3.62ns ± 4%     1.64ns ± 1%     -54.65%  (p=0.000 n=10+10)
    
    name    old allocs/op   new allocs/op   delta
    ---------------------------------------------------------
    IsOdd   0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    66e2409 View commit details
    Browse the repository at this point in the history
  38. uint256: Add bitwise left shift support.

    This adds support for uint256 bitwise left shifting along with
    associated tests to ensure proper functionality.
    
    It includes left shifting an existing uint256 (a << b) and assigning the
    result of left shifting a uint256 to a second one (a <<= b).
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    1114a41 View commit details
    Browse the repository at this point in the history
  39. uint256: Add bitwise left shift benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name           old time/op     new time/op     delta
    -------------------------------------------------------------------------
    Lsh/bits_0      7.1ns ± 3%     2.58ns ± 1%     -63.94%  (p=0.000 n=10+10)
    Lsh/bits_1     14.8ns ± 1%     4.2ns ± 1%      -71.40%  (p=0.000 n=10+10)
    Lsh/bits_64    16.7ns ± 1%     2.7ns ± 1%      -84.00%  (p=0.000 n=10+10)
    Lsh/bits_128   16.9ns ± 2%     2.7ns ± 0%      -84.21%  (p=0.000 n=10+10)
    Lsh/bits_192   16.6ns ± 1%     2.6ns ± 1%      -84.19%  (p=0.000 n=10+10)
    Lsh/bits_255   16.3ns ± 2%     2.8ns ± 2%      -83.11%  (p=0.000 n=10+10)
    Lsh/bits_256   16.9ns ± 2%     2.6ns ± 2%      -84.77%  (p=0.000 n=10+10)
    
    name           old allocs/op   new allocs/op   delta
    ----------------------------------------------------------------
    Lsh/bits_0     0.00            0.00            ~     (all equal)
    Lsh/bits_1     0.00            0.00            ~     (all equal)
    Lsh/bits_64    0.00            0.00            ~     (all equal)
    Lsh/bits_128   0.00            0.00            ~     (all equal)
    Lsh/bits_192   0.00            0.00            ~     (all equal)
    Lsh/bits_255   0.00            0.00            ~     (all equal)
    Lsh/bits_256   0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    7844489 View commit details
    Browse the repository at this point in the history
  40. uint256: Add bitwise right shift support.

    This adds support for uint256 bitwise right shifting along with
    associated tests to ensure proper functionality.
    
    It includes right shifting an existing uint256 (a >> b) and assigning
    the result of right shifting a uint256 to a second one (a >>= b).
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    0084625 View commit details
    Browse the repository at this point in the history
  41. uint256: Add bitwise right shift benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name           old time/op     new time/op     delta
    -------------------------------------------------------------------------
    Rsh/bits_0     8.76ns ± 2%     2.57ns ± 1%     -70.63%  (p=0.000 n=10+10)
    Rsh/bits_1     14.4ns ± 2%     4.3ns ± 2%      -70.28%  (p=0.000 n=10+10)
    Rsh/bits_64    12.8ns ± 1%     2.9ns ± 2%      -77.31%  (p=0.000 n=10+10)
    Rsh/bits_128   11.8ns ± 0%     2.9ns ± 2%      -75.51%  (p=0.000 n=10+10)
    Rsh/bits_192   10.5ns ± 2%     2.6ns ± 1%      -75.17%  (p=0.000 n=10+10)
    Rsh/bits_255   10.5ns ± 3%     2.8ns ± 2%      -73.89%  (p=0.000 n=10+10)
    Rsh/bits_256   5.50ns ± 1%     2.58ns ± 2%     -53.15%  (p=0.000 n=10+10)
    
    name           old allocs/op   new allocs/op   delta
    ----------------------------------------------------------------
    Rsh/bits_0     0.00            0.00            ~     (all equal)
    Rsh/bits_1     0.00            0.00            ~     (all equal)
    Rsh/bits_64    0.00            0.00            ~     (all equal)
    Rsh/bits_128   0.00            0.00            ~     (all equal)
    Rsh/bits_192   0.00            0.00            ~     (all equal)
    Rsh/bits_255   0.00            0.00            ~     (all equal)
    Rsh/bits_256   0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    6fd319e View commit details
    Browse the repository at this point in the history
  42. uint256: Add bitwise not support.

    This adds support to compute the bitwise not of a uint256 along with
    associated tests to ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    a42b8c8 View commit details
    Browse the repository at this point in the history
  43. uint256: Add bitwise not benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name   old time/op     new time/op     delta
    -----------------------------------------------------------------
    Not    25.4ns ± 2%     3.3ns ± 2%      -86.79%  (p=0.000 n=10+10)
    
    name   old allocs/op   new allocs/op   delta
    --------------------------------------------------------
    Not    0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    3ce3e33 View commit details
    Browse the repository at this point in the history
  44. uint256: Add bitwise or support.

    This adds support to compute the bitwise or of two uint256s along with
    associated tests to ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    269eee2 View commit details
    Browse the repository at this point in the history
  45. uint256: Add bitwise or benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name   old time/op     new time/op     delta
    -----------------------------------------------------------------
    Or     17.9ns ± 5%     3.4ns ± 6%      -80.94%  (p=0.000 n=10+10)
    
    name   old allocs/op   new allocs/op   delta
    --------------------------------------------------------
    Or     0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    33601a0 View commit details
    Browse the repository at this point in the history
  46. uint256: Add bitwise and support.

    This adds support to compute the bitwise and of two uint256s along with
    associated tests to ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    97bdac8 View commit details
    Browse the repository at this point in the history
  47. uint256: Add bitwise and benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name   old time/op     new time/op     delta
    -----------------------------------------------------------------
    And    16.7ns ± 5%     3.4ns ± 6%      -79.93%  (p=0.000 n=10+10)
    
    name   old allocs/op   new allocs/op   delta
    --------------------------------------------------------
    And    0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    275afa2 View commit details
    Browse the repository at this point in the history
  48. uint256: Add bitwise xor support.

    This adds support to compute the bitwise xor of two uint256s along with
    associated tests to ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    d176920 View commit details
    Browse the repository at this point in the history
  49. uint256: Add bitwise xor benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name   old time/op     new time/op     delta
    -----------------------------------------------------------------
    Xor    17.9ns ± 5%     3.4ns ± 6%      -80.91%  (p=0.000 n=10+10)
    
    name   old allocs/op   new allocs/op   delta
    --------------------------------------------------------
    Xor    0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    7ba863d View commit details
    Browse the repository at this point in the history
  50. uint256: Add bit length support.

    This adds support for determining the minimum number of bits required to
    represent the current value of a uint256 along with associated tests to
    ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    c0854f6 View commit details
    Browse the repository at this point in the history
  51. uint256: Add bit length benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name       old time/op     new time/op     delta
    ---------------------------------------------------------------------
    bits_64    2.24ns ± 1%     1.94ns ± 3%     -13.04%  (p=0.000 n=10+10)
    bits_128   2.25ns ± 2%     1.96ns ± 2%     -13.17%  (p=0.000 n=10+10)
    bits_192   2.25ns ± 1%     1.60ns ± 1%     -28.65%  (p=0.000 n=10+10)
    bits_255   2.26ns ± 2%     1.61ns ± 1%     -29.04%  (p=0.000 n=10+10)
    
    name       old allocs/op   new allocs/op   delta
    ------------------------------------------------------------
    bits_64    0.00            0.00            ~     (all equal)
    bits_128   0.00            0.00            ~     (all equal)
    bits_192   0.00            0.00            ~     (all equal)
    bits_255   0.00            0.00            ~     (all equal)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    37b4c65 View commit details
    Browse the repository at this point in the history
  52. uint256: Add text formatting support.

    This adds full support for formatting a uint256 along with associated
    tests to ensure proper functionality.
    
    It includes a fmt.Formatter that supports the full suite of the fmt
    package format flags for integral types, a fmt.Stringer, and a separate
    Text method that accepts an output base directly and produces the
    relevant output with fewer allocations than using the standard fmt
    methods.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    4f7eaa8 View commit details
    Browse the repository at this point in the history
  53. uint256: Add text formatting benchmarks.

    The following is a comparison between stdlib big integers (old) and the
    specialized type (new) averaging 10 runs each:
    
    name             old time/op     new time/op     delta
    ---------------------------------------------------------------------------
    Text/base_2      579ns ± 3%      496ns ± 2%      -14.37%  (p=0.000 n=10+10)
    Text/base_8      266ns ± 1%      227ns ± 1%      -14.58%  (p=0.000 n=10+10)
    Text/base_10     536ns ± 1%      458ns ± 2%      -14.58%  (p=0.000 n=10+10)
    Text/base_16     205ns ± 2%      180ns ± 4%      -11.90%  (p=0.000 n=10+10)
    Format/base_2    987ns ±15%      852ns ± 2%      -13.64%  (p=0.000 n=10+10)
    Format/base_8    620ns ± 6%      544ns ± 3%      -12.31%  (p=0.000 n=10+10)
    Format/base_10   888ns ± 1%      726ns ± 1%      -18.25%  (p=0.000 n=10+10)
    Format/base_16   565ns ± 1%      449ns ± 1%      -20.41%  (p=0.000 n=10+10)
    
    name             old allocs/op   new allocs/op   delta
    --------------------------------------------------------------------------
    Text/base_2      2.00 ± 0%       2.00 ± 0%         ~     (all equal)
    Text/base_8      2.00 ± 0%       2.00 ± 0%         ~     (all equal)
    Text/base_10     3.00 ± 0%       2.00 ± 0%      -33.33%  (p=0.000 n=10+10)
    Text/base_16     2.00 ± 0%       2.00 ± 0%         ~     (all equal)
    Format/base_2    5.00 ± 0%       3.00 ± 0%      -40.00%  (p=0.000 n=10+10)
    Format/base_8    5.00 ± 0%       3.00 ± 0%      -40.00%  (p=0.000 n=10+10)
    Format/base_10   6.00 ± 0%       3.00 ± 0%      -50.00%  (p=0.000 n=10+10)
    Format/base_16   5.00 ± 0%       3.00 ± 0%      -40.00%  (p=0.000 n=10+10)
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    4653cbc View commit details
    Browse the repository at this point in the history
  54. uint256: Add conversion to stdlib big int support.

    This adds convenience methods for converting a uint256 to a standard
    library big integer along with associated tests to ensure proper
    functionality.
    
    It includes a method that allows an existing big integer to be reused
    thereby potentially saving allocations as well as a method that returns
    a new big integer.  The latter is often more convenient to use, but is
    also virtually guaranteed to cause an allocation.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    6065dd8 View commit details
    Browse the repository at this point in the history
  55. uint256: Add conversion to stdlib big int benchmark.

    The following shows the typical performance of converting a uint256 to a
    standard library big integer using one that already exists:
    
    Uint256PutBig   43651442   27.29 ns/op   0 B/op   0 allocs/op
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    15eac53 View commit details
    Browse the repository at this point in the history
  56. uint256: Add conversion from stdlib big int support.

    This adds a convenience method for converting a standard library big
    integer to a uint256 (modulo 2^256) along with associated tests to
    ensure proper functionality.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    8dbc97e View commit details
    Browse the repository at this point in the history
  57. uint256: Add conversion from stdlib big int benchmark.

    The following shows the typical performance of converting a standard
    library big integer that has already been reduced modulo 2^256 to a
    uint256:
    
    Uint256SetBig   26944130   44.45 ns/op   0 B/op   0 allocs/op
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    3d83510 View commit details
    Browse the repository at this point in the history
  58. uint256: Add basic usage example.

    This adds an example of calculating the result of dividing a max
    unsigned 256-bit integer by a max unsigned 128-bit integer and
    outputting that result in hex with leading zeros.
    
    This is part of a series of commits to fully implement the uint256
    package.
    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    7abc0d9 View commit details
    Browse the repository at this point in the history
  59. uint256: Add README.md.

    davecgh committed Nov 19, 2021
    Configuration menu
    Copy the full SHA
    8f3fd5a View commit details
    Browse the repository at this point in the history