MCPcopy Create free account
hub / github.com/BitVM/BitVM / u4_add_carry_nested

Function u4_add_carry_nested

bitvm/src/u4/u4_add.rs:101–118  ·  view source on GitHub ↗

Calculates the modulo 16 of the u4 at the top of the stack also with the quotient, parameters being internal values

(current: u32, limit: u32)

Source from the content-addressed store, hash-verified

99
100/// Calculates the modulo 16 of the u4 at the top of the stack also with the quotient, parameters being internal values
101pub fn u4_add_carry_nested(current: u32, limit: u32) -> Script {
102 script! {
103 OP_DUP
104 OP_16
105 OP_GREATERTHANOREQUAL
106 OP_IF
107 OP_16
108 OP_SUB
109 if current + 1 == limit {
110 { current }
111 } else {
112 { u4_add_carry_nested(current+1, limit)}
113 }
114 OP_ELSE
115 { current }
116 OP_ENDIF
117 }
118}
119
120/// Calculates the modulo 16 of the u4 at the top of the stack, parameters being internal values
121pub fn u4_add_nested(current: u32, limit: u32) -> Script {

Callers 1

u4_add_nibble_stackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected