BAN/LibC: Implement remainder
This is basically just fmod but with fprem1 instead of fprem
This commit is contained in:
parent
5c20d5e291
commit
e9c81477d7
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ FUNC_EXPR1(nearbyint, BAN::Math::rint(a))
|
|||
FUNC_EXPR2(nextafter, nextafter_impl(a, b))
|
||||
FUNC_EXPR2_TYPE(nexttoward, long double, nextafter_impl(a, b))
|
||||
FUNC_EXPR2(pow, ({ if (isnan(a)) return a; if (isnan(b)) return b; BAN::Math::pow(a, b); }))
|
||||
// remainder
|
||||
BAN_FUNC2(remainder)
|
||||
// remquo
|
||||
BAN_FUNC1(rint)
|
||||
FUNC_EXPR1(round, ({ if (!isfinite(a)) return a; BAN::Math::round(a); }))
|
||||
|
|
|
|||
Loading…
Reference in New Issue