MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / ParseBig256

Function ParseBig256

utils/big.go:78–93  ·  view source on GitHub ↗

ParseBig256 parses s as a 256 bit integer in decimal or hexadecimal syntax. Leading zeros are accepted. The empty string parses as zero.

(s string)

Source from the content-addressed store, hash-verified

76// ParseBig256 parses s as a 256 bit integer in decimal or hexadecimal syntax.
77// Leading zeros are accepted. The empty string parses as zero.
78func ParseBig256(s string) (*big.Int, bool) {
79 if s == "" {
80 return new(big.Int), true
81 }
82 var bigint *big.Int
83 var ok bool
84 if len(s) >= 2 && (s[:2] == "0x" || s[:2] == "0X") {
85 bigint, ok = new(big.Int).SetString(s[2:], 16)
86 } else {
87 bigint, ok = new(big.Int).SetString(s, 10)
88 }
89 if ok && bigint.BitLen() > 256 {
90 bigint, ok = nil, false
91 }
92 return bigint, ok
93}
94
95// MustParseBig256 parses s as a 256 bit big integer and panics if the string is invalid.
96func MustParseBig256(s string) *big.Int {

Callers 2

UnmarshalTextMethod · 0.85
MustParseBig256Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected