diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-01-23 15:53:56 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-01-23 15:53:56 +0100 |
commit | 6d012d2df00d742329a05aed46f657f439023fee (patch) | |
tree | 01b049f1ab923e7f55fb67d1d52ceac1566d1d76 /sys/src/ape/lib/ap/plan9 | |
parent | b5c7158f39e448d70052076b83d04ef22d794e5a (diff) |
ape: apply infinite recursion in fmod() fix (thanks jxy and ality)
Apply changeset 2880:cab2b9d13a73 to ape's fmod() implementation.
Remove the unused math/fmod.c copy.
Diffstat (limited to 'sys/src/ape/lib/ap/plan9')
-rw-r--r-- | sys/src/ape/lib/ap/plan9/frexp.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/src/ape/lib/ap/plan9/frexp.c b/sys/src/ape/lib/ap/plan9/frexp.c index 0d81f52c7..2e814dd19 100644 --- a/sys/src/ape/lib/ap/plan9/frexp.c +++ b/sys/src/ape/lib/ap/plan9/frexp.c @@ -73,6 +73,16 @@ modf(double d, double *ip) Cheat x; int e; + x.d = d; + e = (x.ms >> SHIFT) & MASK; + if(e == MASK){ + *ip = d; + if(x.ls != 0 || (x.ms & 0xfffffL) != 0) /* NaN */ + return d; + /* ±Inf */ + x.ms &= 0x80000000L; + return x.d; + } if(d < 1) { if(d < 0) { f = modf(-d, ip); @@ -82,8 +92,7 @@ modf(double d, double *ip) *ip = 0; return d; } - x.d = d; - e = ((x.ms >> SHIFT) & MASK) - BIAS; + e -= BIAS; if(e <= SHIFT+1) { x.ms &= ~(0x1fffffL >> e); x.ls = 0; |