Remainder negative numerator bug fixed (#641)

Co-authored-by: Angelos Katharopoulos <a_katharopoulos@apple.com>
This commit is contained in:
Abdussamet Türker
2024-02-10 03:49:14 +03:00
committed by GitHub
parent b57bd0488d
commit b670485185
7 changed files with 95 additions and 56 deletions

View File

@@ -35,6 +35,16 @@ inline bool operator>(const complex64_t& a, const complex64_t& b) {
return (a.real() > b.real()) || (a.real() == b.real() && a.imag() > b.imag());
}
inline complex64_t operator%(complex64_t a, complex64_t b) {
auto real = a.real() - (b.real() * static_cast<int64_t>(a.real() / b.real()));
auto imag = a.imag() - (b.imag() * static_cast<int64_t>(a.imag() / b.imag()));
if (real != 0 && (real < 0 != b.real() < 0))
real += b.real();
if (imag != 0 && (imag < 0 != b.imag() < 0))
imag += b.imag();
return {real, imag};
}
inline bool operator<=(const complex64_t& a, const complex64_t& b) {
return operator>=(b, a);
}