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

Function u4_logic_with_table_stack

bitvm/src/u4/u4_logic_stack.rs:83–95  ·  view source on GitHub ↗

Does the given logical operation with parameters

(
    stack: &mut StackTracker,
    lookup_table: StackVariable,
    logic_table: StackVariable,
)

Source from the content-addressed store, hash-verified

81
82/// Does the given logical operation with parameters
83pub fn u4_logic_with_table_stack(
84 stack: &mut StackTracker,
85 lookup_table: StackVariable,
86 logic_table: StackVariable,
87) -> StackVariable {
88 let use_full_table = logic_table.size() > 136;
89 if !use_full_table {
90 stack.custom(u4_sort(), 0, false, 0, "sort");
91 }
92 stack.get_value_from_table(lookup_table, None);
93 stack.op_add();
94 stack.get_value_from_table(logic_table, None)
95}
96
97/// Calculates the bitwise AND of top 2 u4 values using XOR tables
98/// Uses the formula (a and b) = ((a + b) - a XOR b) >> 1

Callers 7

u4_and_with_xor_stackFunction · 0.85
test_xorFunction · 0.85
test_xor_halfFunction · 0.85
test_and_halfFunction · 0.85
calculate_s_nibFunction · 0.85

Calls 1

u4_sortFunction · 0.85

Tested by 3

test_xorFunction · 0.68
test_xor_halfFunction · 0.68
test_and_halfFunction · 0.68