8#ifndef LIBFXD_ROUND_DIV_HPP
9#define LIBFXD_ROUND_DIV_HPP
17#include "detail/bias.hpp"
18#include "detail/raw-div.hpp"
19#include "detail/shift.hpp"
28 template<fixed_po
int Fxd>
35 const auto raw_a = a.raw_value;
36 const auto raw_b = b.raw_value;
37 const auto r = detail::raw::div<Fxd::frac_bits>(raw_a, raw_b);
41 auto [c, expo, rem] = *r;
44 const int offset = expo + Fxd::frac_bits;
47 if (c < 0 && offset < 0)
48 c += detail::make_bias_for(-offset, c);
50 const auto d = detail::shl(c, offset);
52 return Fxd::from_raw(d);
62 template<fixed_po
int Fxd>
69 const auto raw_a = a.raw_value;
70 const auto raw_b = b.raw_value;
71 const auto r = detail::raw::div<Fxd::frac_bits>(raw_a, raw_b);
75 auto [c, expo, rem] = *r;
79 const bool neg = (a.raw_value < 0) != (b.raw_value < 0);
82 const int offset = expo + Fxd::frac_bits;
90 c += detail::make_bias_for(-offset, c);
92 const auto d = detail::shl(c, offset);
94 return Fxd::from_raw(d);
104 template<fixed_po
int Fxd>
111 const auto raw_a = a.raw_value;
112 const auto raw_b = b.raw_value;
113 const auto r = detail::raw::div<Fxd::frac_bits>(raw_a, raw_b);
117 auto [c, expo, rem] = *r;
119 const bool neg = (a.raw_value < 0) != (b.raw_value < 0);
122 const int offset = expo + Fxd::frac_bits;
130 const auto d = detail::shl(c, offset);
132 return Fxd::from_raw(d);
This is the namespace where the entire library is defined.