Skip to content

Commit

Permalink
Introduce Value::as_i32
Browse files Browse the repository at this point in the history
To help make #596 easier to
read and reason about.
  • Loading branch information
matthiasgoergens committed Dec 11, 2024
1 parent c4e729a commit ed6797b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 1 addition & 3 deletions ceno_zkvm/src/instructions/riscv/mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,7 @@ impl<E: ExtensionField> Signed<E> {
lkm,
*val.as_u16_limbs().last().unwrap() as u64,
)?;
let signed_val = val.as_u32() as i32;

Ok(signed_val)
Ok(val.as_i32())
}

pub fn expr(&self) -> Expression<E> {
Expand Down
5 changes: 5 additions & 0 deletions ceno_zkvm/src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,11 @@ impl<'a, T: Into<u64> + From<u32> + Copy + Default> Value<'a, T> {
self.as_u64() as u32
}

/// Convert the limbs to a u32 value
pub fn as_i32(&self) -> i32 {
self.as_u32() as i32
}

pub fn u16_fields<F: SmallField>(&self) -> Vec<F> {
self.limbs.iter().map(|v| F::from(*v as u64)).collect_vec()
}
Expand Down

0 comments on commit ed6797b

Please sign in to comment.