mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Merge branch 'fixedmul-c-fix' into 'master'
Correct C FixedMul() off-by-one errors See merge request STJr/SRB2!245
This commit is contained in:
commit
650e0eafce
1 changed files with 3 additions and 1 deletions
|
@ -33,7 +33,9 @@
|
|||
*/
|
||||
fixed_t FixedMul(fixed_t a, fixed_t b)
|
||||
{
|
||||
return (fixed_t)((((INT64)a * b) ) / FRACUNIT);
|
||||
// Need to cast to unsigned before shifting to avoid undefined behaviour
|
||||
// for negative integers
|
||||
return (fixed_t)(((UINT64)((INT64)a * b)) >> FRACBITS);
|
||||
}
|
||||
|
||||
#endif //__USE_C_FIXEDMUL__
|
||||
|
|
Loading…
Reference in a new issue