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 Dec 21, 2023
1 parent d9dc86b commit 4a34e76
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 4a34e76

Please sign in to comment.