Skip to content

Commit

Permalink
fix i128 diff operation
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoGiachetta committed Oct 3, 2024
1 parent 65825fb commit 69aa734
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ fn eval<'a>(
self::starknet::eval(registry, selector, args, syscall_handler)
}
CoreConcreteLibfunc::Struct(selector) => self::r#struct::eval(registry, selector, args),
CoreConcreteLibfunc::Uint128(selector) => {self::uint128::eval(registry, selector, args)},
CoreConcreteLibfunc::Uint128(selector) => self::uint128::eval(registry, selector, args),
CoreConcreteLibfunc::Uint16(selector) => self::uint16::eval(registry, selector, args),
CoreConcreteLibfunc::Uint256(selector) => self::uint252::eval(registry, selector, args),
CoreConcreteLibfunc::Uint32(selector) => self::uint32::eval(registry, selector, args),
Expand Down
6 changes: 4 additions & 2 deletions src/vm/int128.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::u128;

use cairo_lang_sierra::{
extensions::{
core::{CoreLibfunc, CoreType},
Expand Down Expand Up @@ -44,10 +46,10 @@ fn eval_diff(
if lhs >= rhs {
EvalAction::NormalBranch(
0,
smallvec![range_check, Value::I128(lhs - rhs)],
smallvec![range_check, Value::U128((lhs - rhs).try_into().unwrap())],
)
} else {
EvalAction::NormalBranch(1, smallvec![range_check, Value::I128(lhs.wrapping_sub(rhs))])
EvalAction::NormalBranch(1, smallvec![range_check, Value::U128(lhs.wrapping_sub(rhs).try_into().unwrap())])
}
}

Expand Down
1 change: 0 additions & 1 deletion src/vm/uint128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub fn eval(
selector: &Uint128Concrete,
args: Vec<Value>,
) -> EvalAction {
dbg!(&args);
match selector {
Uint128Concrete::Const(info) => eval_const(registry, info, args),
Uint128Concrete::Operation(info) => eval_operation(registry, info, args),
Expand Down

0 comments on commit 69aa734

Please sign in to comment.