Skip to content

Commit

Permalink
Update riscv/arith.h
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Brunie <[email protected]>
  • Loading branch information
nibrunieAtSi5 authored and nibrunie committed Aug 11, 2024
1 parent 64c8c41 commit 6ddf910
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion riscv/arith.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inline int64_t mulhsu(int64_t a, uint64_t b)
{
int negate = a < 0;
uint64_t res = mulhu(a < 0 ? -(uint64_t)a : a, b);
return negate ? ~res + (a * b == 0) : res;
return negate ? ~res + ((uint64_t)a * b == 0) : res;
}

//ref: https://locklessinc.com/articles/sat_arithmetic/
Expand Down

0 comments on commit 6ddf910

Please sign in to comment.