Skip to main content

handle_u64_div

Function handle_u64_div 

Source
pub fn handle_u64_div(
    process: &ProcessorState<'_>,
) -> Result<Vec<AdviceMutation>, EventError>
Expand description

U64_DIV system event handler.

Pushes the result of u64 division (both the quotient and the remainder) onto the advice stack.

Inputs: Operand stack: [event_id, b_lo, b_hi, a_lo, a_hi, …] Advice stack: […]

Outputs: Advice stack: [q_lo, q_hi, r_lo, r_hi, …]

Where (a_lo, a_hi) and (b_lo, b_hi) are the 32-bit limbs of the dividend and the divisor respectively (with lo representing the 32 least significant bits and hi representing the 32 most significant bits). Similarly, (q_lo, q_hi) and (r_lo, r_hi) represent the quotient and the remainder respectively.

§Errors

Returns an error if the divisor is ZERO.