github.com/holiman/uint256 源码阅读
- // uint256: Fixed size 256-bit math library
- // Copyright 2018-2020 uint256 Authors
- // SPDX-License-Identifier: BSD-3-Clause
-
- // Package math provides integer math utilities.
-
- package uint256
-
- import (
- "encoding/binary"
- "math"
- "math/big"
- "math/bits"
- )
-
- // Int is represented as an array of 4 uint64, in little-endian order,
- // so that Int[3] is the most significant, and Int[0] is the least significant
- type Int [4]uint64 //Int定义为一个长度为4的uint64数组. 所以一共4*64位无符号.
- // 0是最低位, 3是最高位.
- // NewInt returns a new initialized Int.
- func NewInt(val uint64) *Int {
- z := &Int{}
- z.SetUint64(val)
- return z
- }
-
- // SetBytes interprets buf as the bytes of a big-endian unsigned
- // integer, sets z to that value, and returns z.
- // If buf is larger than 32 bytes