Skip to content

Commit

Permalink
core/math/fixed: rewrite BrFixedDiv() to not use float intermediates
Browse files Browse the repository at this point in the history
  • Loading branch information
vs49688 committed May 18, 2024
1 parent 8570937 commit 45d37e4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/math/fixed.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ br_fixed_ls BR_PUBLIC_ENTRY BrFixedSqr4(br_fixed_ls a, br_fixed_ls b, br_fixed_l

br_fixed_ls BR_PUBLIC_ENTRY BrFixedDiv(br_fixed_ls numerator, br_fixed_ls denominator)
{
br_scalar n = BrFixedToScalar(numerator);
br_scalar d = BrFixedToScalar(denominator);
return BrScalarToFixed(n / d);
if(denominator == 0)
return 0;

return (br_fixed_ls)(((br_uint_64)numerator << 16) / denominator);
}

br_fixed_ls BR_PUBLIC_ENTRY BrFixedSin(br_fixed_luf a)
Expand Down

0 comments on commit 45d37e4

Please sign in to comment.