Lines Matching defs:m_x
40 // fmod = m_x * 2^e_x - tquot * m_y * 2^e_y
41 // = 2^e_y * (m_x * 2^(e_x - e^y) - tquot * m_y).
45 // Input x,y in the algorithm is represented (mathematically) like m_x*2^e_x
53 // a = m_x * 2^e_x, b = m_y * 2^e_y, N = 2^k
54 // r(k) = a % b = (m_x * 2^e_x) % (2^k * m_y * 2^e_y)
55 // = 2^(e_y + k) * (m_x * 2^(e_x - e_y - k) % m_y)
56 // r(k) = m_r * 2^e_r = (m_x % m_y) * 2^(m_y + k)
57 // = (2^p * (m_x % m_y) * 2^(e_y + k - p))
58 // m_r = 2^p * (m_x % m_y), e_r = m_y + k - p
61 // First, let write x = m_x * 2^e_x and y = m_y * 2^e_y with m_x, m_y, e_x, e_y
62 // are integers (m_x amd m_y positive).
66 // m_x *= 2; --e_x; // m_x * 2^e_x == 2 * m_x * 2^(e_x - 1)
67 // m_x %= m_y;
69 // On the other hand, the algorithm exploits the fact that m_x, m_y are the
72 // the iteration, we can left shift m_x as many bits as the storage integer
76 // m_x <<= 11; e_x -= 11; // m_x * 2^e_x == 2^11 * m_x * 2^(e_x - 11)
77 // m_x %= m_y;
82 // The m_x shift in the loop can be 62 instead of 11 for double.
91 // 2) m_x = m_x % m_y.
92 // 3) Move m_x maximum to left. Note that after (m_x = m_x % m_y) CLZ in m_x
93 // is not lower than CLZ in m_y. m_x=0b00001001 e_x = 100, m_x=0b10010000,
98 // Converting x,y to (m_x,e_x),(m_y, e_y): CTZ/shift/AND/OR/if. Loop count:
99 // (m_x - m_y) / (64 - "length of m_y").
107 // result = (m_x * 2^(e_x - e_y)) % m_y.
109 // result = m_x % m_y.
122 T m_x, T m_y) {
125 m_x <<= sides_zeroes_count;
126 m_x %= m_y;
128 m_x <<= exp_diff;
129 m_x %= m_y;
130 return m_x;
136 T m_x, T m_y) {
142 T hd = (m_x * inv_hy) >> (LENGTH - sides_zeroes_count);
143 m_x <<= sides_zeroes_count;
144 m_x -= hd * m_y;
145 while (LIBC_UNLIKELY(m_x > m_y))
146 m_x -= m_y;
148 T hd = (m_x * inv_hy) >> (LENGTH - exp_diff);
149 m_x <<= exp_diff;
150 m_x -= hd * m_y;
151 while (LIBC_UNLIKELY(m_x > m_y))
152 m_x -= m_y;
154 m_x <<= exp_diff;
155 m_x %= m_y;
157 return m_x;
213 StorageType m_x = sx.get_explicit_mantissa();
216 ? (m_x - m_y)
217 : static_cast<StorageType>(m_x << (e_x - e_y)) % m_y;
231 U m_x = static_cast<U>(sx.get_explicit_mantissa());
262 m_x <<= left_shift;
266 m_x %= m_y;
267 if (LIBC_UNLIKELY(m_x == 0))
271 return FPB::make_value(static_cast<StorageType>(m_x), e_y);
274 m_x = DivisionHelper::execute(exp_diff, sides_zeroes_count, m_x, m_y);
275 return FPB::make_value(static_cast<StorageType>(m_x), e_y);