MCPcopy Index your code
hub / github.com/btcsuite/btcd / Int32

Method Int32

txscript/scriptnum.go:160–170  ·  view source on GitHub ↗

Int32 returns the script number clamped to a valid int32. That is to say when the script number is higher than the max allowed int32, the max int32 value is returned and vice versa for the minimum value. Note that this behavior is different from a simple int32 cast because that truncates and the c

()

Source from the content-addressed store, hash-verified

158// out of range before being reinterpreted as an integer, this will provide the
159// correct behavior.
160func (n scriptNum) Int32() int32 {
161 if n > maxInt32 {
162 return maxInt32
163 }
164
165 if n < minInt32 {
166 return minInt32
167 }
168
169 return int32(n)
170}
171
172// MakeScriptNum interprets the passed serialized bytes as an encoded integer
173// and returns the result as a script number.

Callers 5

TestScriptNumInt32Function · 0.80
opcodePickFunction · 0.80
opcodeRollFunction · 0.80
opcodeCheckMultiSigFunction · 0.80

Calls

no outgoing calls

Tested by 2

TestScriptNumInt32Function · 0.64