BAN/LibC: Implement remainder

This is basically just fmod but with fprem1 instead of fprem
This commit is contained in:
2026-03-25 01:06:45 +02:00
parent 5c20d5e291
commit e9c81477d7
2 changed files with 18 additions and 2 deletions

View File

@@ -172,7 +172,23 @@ namespace BAN::Math
"jne 1b;"
: "+t"(a)
: "u"(b)
: "ax"
: "ax", "cc"
);
return a;
}
template<floating_point T>
inline constexpr T remainder(T a, T b)
{
asm(
"1:"
"fprem1;"
"fnstsw %%ax;"
"testb $4, %%ah;"
"jne 1b;"
: "+t"(a)
: "u"(b)
: "ax", "cc"
);
return a;
}