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
()
| 158 | // out of range before being reinterpreted as an integer, this will provide the |
| 159 | // correct behavior. |
| 160 | func (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. |
no outgoing calls