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

Function opcodeAbs

txscript/opcode.go:1472–1483  ·  view source on GitHub ↗

opcodeAbs treats the top item on the data stack as an integer and replaces it it with its absolute value. Stack transformation: [... x1 x2] -> [... x1 abs(x2)]

(op *opcode, data []byte, vm *Engine)

Source from the content-addressed store, hash-verified

1470//
1471// Stack transformation: [... x1 x2] -> [... x1 abs(x2)]
1472func opcodeAbs(op *opcode, data []byte, vm *Engine) error {
1473 m, err := vm.dstack.PopInt()
1474 if err != nil {
1475 return err
1476 }
1477
1478 if m < 0 {
1479 m = -m
1480 }
1481 vm.dstack.PushInt(m)
1482 return nil
1483}
1484
1485// opcodeNot treats the top item on the data stack as an integer and replaces
1486// it with its "inverted" value (0 becomes 1, non-zero becomes 0).

Callers

nothing calls this directly

Calls 2

PopIntMethod · 0.80
PushIntMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…