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

Function u4_rshift_stack

bitvm/src/u4/u4_shift_stack.rs:38–45  ·  view source on GitHub ↗

Calculates n'th right shift of the top u4 element with both tables

(stack: &mut StackTracker, tables: StackVariable, n: u32)

Source from the content-addressed store, hash-verified

36
37/// Calculates n'th right shift of the top u4 element with both tables
38pub fn u4_rshift_stack(stack: &mut StackTracker, tables: StackVariable, n: u32) -> StackVariable {
39 assert!((1..4).contains(&n));
40 if n == 3 {
41 stack.number(8);
42 return stack.op_greaterthanorequal();
43 }
44 stack.get_value_from_table(tables, Some(32 * (n - 1)))
45}
46
47/// Calculates n'th left shift of the top u4 element with both tables
48pub fn u4_lshift_stack(stack: &mut StackTracker, tables: StackVariable, n: u32) -> StackVariable {

Callers 5

u4_2_nib_shift_stackFunction · 0.85
test_rshiftFunction · 0.85
u4_and_with_xor_stackFunction · 0.85
calculate_s_nibFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_rshiftFunction · 0.68