Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Value::as_i32 #732

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-paste error: should be Convert the limbs to an i32 value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

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