libc: fprem fmod()

This commit is contained in:
K. Lange 2018-12-08 13:33:25 +09:00
parent 52f35de578
commit d63c98b6bf
1 changed files with 9 additions and 8 deletions

View File

@ -78,14 +78,15 @@ float fabsf(float x) {
double fmod(double x, double y) { double fmod(double x, double y) {
MATH; MATH;
if (x >= 0.0) {
while (x > y) { long double out;
x -= y; asm volatile (
} "1: fprem;" /* Partial remainder */
return x; " fnstsw %%ax;" /* store status word */
} else { " sahf;" /* store AX (^ FPU status) into flags */
return 0.0; " jp 1b;" /* jump back to 1 above if parity flag==1 */
} : "=t"(out) : "0"(x), "u"(y) : "ax", "cc");
return out;
} }
double sqrt(double x) { double sqrt(double x) {