Commit 363fb932 authored by Richard Gobeille's avatar Richard Gobeille

engine: use libdivide in fix16_div()

parent e14fc845
#include "fix16.h"
#include "pragmas.h"
#include "fix16_int64.h"
/* Subtraction and addition with overflow detection.
......@@ -147,7 +149,7 @@ FIXMATH_FUNC_ATTRS fix16_t fix16_div(fix16_t a, fix16_t b)
if (divider & 0xFFF00000)
{
uint32_t shifted_div = ((divider >> 17) + 1);
quotient = remainder / shifted_div;
quotient = divideu32(remainder, shifted_div);
remainder -= ((uint64_t)quotient * divider) >> 17;
}
......@@ -166,7 +168,7 @@ FIXMATH_FUNC_ATTRS fix16_t fix16_div(fix16_t a, fix16_t b)
remainder <<= shift;
bit_pos -= shift;
uint32_t div = remainder / divider;
uint32_t div = divideu32(remainder, divider);
remainder = remainder % divider;
quotient += div << bit_pos;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment