Skip to content

Commit

Permalink
Merge pull request #337 from HigherOrderCO/fix_i24_comparison
Browse files Browse the repository at this point in the history
Fix i24 comparison
  • Loading branch information
VictorTaelin authored May 23, 2024
2 parents fe8cbe7 + 23cb1f2 commit a526923
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/hvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,10 @@ static inline Numb operate(Numb a, Numb b) {
case FP_DIV: return new_i24(bv / av);
case OP_REM: return new_i24(av % bv);
case FP_REM: return new_i24(bv % av);
case OP_EQ: return new_i24(av == bv);
case OP_NEQ: return new_i24(av != bv);
case OP_LT: return new_i24(av < bv);
case OP_GT: return new_i24(av > bv);
case OP_EQ: return new_u24(av == bv);
case OP_NEQ: return new_u24(av != bv);
case OP_LT: return new_u24(av < bv);
case OP_GT: return new_u24(av > bv);
case OP_AND: return new_i24(av & bv);
case OP_OR: return new_i24(av | bv);
case OP_XOR: return new_i24(av ^ bv);
Expand Down
8 changes: 4 additions & 4 deletions src/hvm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,10 @@ __device__ __host__ inline Numb operate(Numb a, Numb b) {
case FP_DIV: return new_i24(bv / av);
case OP_REM: return new_i24(av % bv);
case FP_REM: return new_i24(bv % av);
case OP_EQ: return new_i24(av == bv);
case OP_NEQ: return new_i24(av != bv);
case OP_LT: return new_i24(av < bv);
case OP_GT: return new_i24(av > bv);
case OP_EQ: return new_u24(av == bv);
case OP_NEQ: return new_u24(av != bv);
case OP_LT: return new_u24(av < bv);
case OP_GT: return new_u24(av > bv);
case OP_AND: return new_i24(av & bv);
case OP_OR: return new_i24(av | bv);
case OP_XOR: return new_i24(av ^ bv);
Expand Down
8 changes: 4 additions & 4 deletions src/hvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ impl Numb {
FP_DIV => Numb::new_i24(bv.wrapping_div(av)),
OP_REM => Numb::new_i24(av.wrapping_rem(bv)),
FP_REM => Numb::new_i24(bv.wrapping_rem(av)),
OP_EQ => Numb::new_i24((av == bv) as i32),
OP_NEQ => Numb::new_i24((av != bv) as i32),
OP_LT => Numb::new_i24((av < bv) as i32),
OP_GT => Numb::new_i24((av > bv) as i32),
OP_EQ => Numb::new_u24((av == bv) as u32),
OP_NEQ => Numb::new_u24((av != bv) as u32),
OP_LT => Numb::new_u24((av < bv) as u32),
OP_GT => Numb::new_u24((av > bv) as u32),
OP_AND => Numb::new_i24(av & bv),
OP_OR => Numb::new_i24(av | bv),
OP_XOR => Numb::new_i24(av ^ bv),
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source: tests/run.rs
expression: rust_output
input_file: tests/programs/i24.hvm
---
Result: {+12 {+8 {+20 {+5 {+0 {+0 {+1 {+0 {+1 {+2 {+10 {+8 {+8388607 {-8388608 {+1 {+1 {-1 {-1 *}}}}}}}}}}}}}}}}}}
Result: {+12 {+8 {+20 {+5 {+0 {0 {1 {0 {1 {+2 {+10 {+8 {+8388607 {-8388608 {+1 {+1 {-1 {-1 *}}}}}}}}}}}}}}}}}}

0 comments on commit a526923

Please sign in to comment.