summaryrefslogtreecommitdiff
path: root/src/math
AgeCommit message (Collapse)AuthorFilesLines
2012-11-13math: simplify hypot and hypotf using scalbnSzabolcs Nagy2-11/+4
this also fixes overflow/underflow raising and excess precision issues (as those are handled well in scalbn)
2012-11-13math: use '#pragma STDC FENV_ACCESS ON' when fenv is accessedSzabolcs Nagy9-0/+10
2012-11-13math: excess precision fix modf, modff, scalbn, scalbnfSzabolcs Nagy4-22/+18
old code was correct only if the result was stored (without the excess precision) or musl was compiled with -ffloat-store. now we use STRICT_ASSIGN to work around the issue. (see note 160 in c11 section 6.8.6.4)
2012-11-13math: fix scalbn and scalbnf on overflow/underflowSzabolcs Nagy2-10/+24
old code was correct only if the result was stored (without the excess precision) or musl was compiled with -ffloat-store. (see note 160 in n1570.pdf section 6.8.6.4)
2012-11-13math: fix nextafter and nexttoward on maxdbl and maxflt inputSzabolcs Nagy4-4/+4
old code (return x+x;) returns correct value and raises correct flags only if the result is stored as double (or float)
2012-11-13math: raise flags in logl.c on <= 0 argumentsSzabolcs Nagy2-9/+3
2012-11-13math: fix logb*.c exceptions now that ilogb raises invalidSzabolcs Nagy3-25/+17
2012-11-13math: raise flags in log2l.c on <= 0 arguments, and fix volatileSzabolcs Nagy1-8/+3
2012-11-13math: raise exception flags in log1pl.c on <= -1 argumentsSzabolcs Nagy1-7/+2
2012-11-12math: raise invalid flag in ilogb*.c on +-0, +-inf and nanSzabolcs Nagy3-6/+18
2012-11-12math: fix exception behaviour of expm1l.c on inf and nanSzabolcs Nagy1-13/+7
2012-11-12math: fix long double constants in exp10l.cSzabolcs Nagy1-2/+2
2012-08-13Merge remote-tracking branch 'nsz/exp'Rich Felker2-40/+35
2012-08-13remove significandlRich Felker1-7/+0
this function never existed historically; since the float/double functions it's based on are nonstandard and deprecated, there's really no justification for its existence except that glibc has it. it can be added back if there's ever really a need...
2012-08-13add significand[fl] math functionsRich Felker3-0/+21
2012-08-08math: fix exp.s on i386 and x86_64 so the exception flags are correctnsz2-40/+35
exp(inf), exp(-inf), exp(nan) used to raise wrong flags
2012-07-02fix missing prototype and simplify sincosl on ld64 archsRich Felker1-4/+2
2012-07-02fix invalid implicit pointer conversion in ld64 modflRich Felker1-1/+1
2012-06-20math: fix fma bug on x86 (found by Bruno Haible with gnulib)nsz1-2/+10
The long double adjustment was wrong: The usual check is mant_bits & 0x7ff == 0x400 before doing a mant_bits++ or mant_bits-- adjustment since this is the only case when rounding an inexact ld80 into double can go wrong. (only in nearest rounding mode) After such a check the ++ and -- is ok (the mantissa will end in 0x401 or 0x3ff). fma is a bit different (we need to add 3 numbers with correct rounding: hi_xy + lo_xy + z so we should survive two roundings at different places without precision loss) The adjustment in fma only checks for zero low bits mant_bits & 0x3ff == 0 this way the adjusted value is correct when rounded to double or *less* precision. (this is an important piece in the fma puzzle) Unfortunately in this case the -- is not a correct adjustment because mant_bits might underflow so further checks are needed and this was the source of the bug.
2012-06-20support ld80 pseudo-denormal invalid bit patterns; treat them as nanRich Felker1-2/+5
this is silly, but it makes apps that read binary junk and interpret it as ld80 "safer", and it gets gnulib to stop replacing printf...
2012-06-02use fistpll mnemonic instead of fistpq (more widely supported) on x86_64 tooRich Felker1-1/+1
this was fixed previously on i386 but the corresponding code on x86_64 was missed.
2012-05-08math: fix remquo.c when x==-y and a subnormal remainder bug as wellnsz3-5/+8
backported fix from freebsd: http://svnweb.FreeBSD.org/base?view=revision&revision=233973
2012-05-07some assemblers don't like fistpq; use the alt. mnemonic fistpllRich Felker3-3/+3
2012-05-06add FORCE_EVAL macro to evaluate float expr for their side effectnsz5-24/+12
updated nextafter* to use FORCE_EVAL, it can be used in many other places in the math code to improve readability.
2012-05-06fix unused variable warnings in new nextafter/nexttoward codeRich Felker5-6/+12
apparently initializing a variable is not "using" it but assigning to it is "using" it. i don't really like this fix, but it's better than trying to make a bigger cleanup just before a release, and it should work fine (tested against nsz's math tests).
2012-05-06math: nextafter and nexttoward cleanupnsz5-291/+176
make nexttoward, nexttowardf independent of long double representation. fix nextafterl: it did not raise underflow flag when the result was 0.
2012-05-05math: change the formula used for acos.snsz2-20/+16
old: 2*atan2(sqrt(1-x),sqrt(1+x)) new: atan2(fabs(sqrt((1-x)*(1+x))),x) improvements: * all edge cases are fixed (sign of zero in downward rounding) * a bit faster (here a single call is about 131ns vs 162ns) * a bit more precise (at most 1ulp error on 1M uniform random samples in [0,1), the old formula gave some 2ulp errors as well)
2012-05-01support alternate glibc name pow10 for exp10Rich Felker3-0/+9
2012-04-30add C stub for sqrtl (already implemented in asm on i386 and x86_64)Rich Felker1-0/+9
2012-04-30first try at writing an efficient and "correct" exp10Rich Felker3-0/+55
this is a nonstandard function so it's not clear what conditions it should satisfy. my intent is that it be fast and exact for positive integral exponents when the result fits in the destination type, and fast and correctly rounded for small negative integral exponents. otherwise we aim for at most 1ulp error; it seems to differ from pow by at most 1ulp and it's often 2-5 times faster than pow.
2012-04-29fix typo in the x86_64 rounding asmRich Felker4-4/+4
2012-04-29new math asm (abs/rounding) for x86_64Rich Felker6-0/+36
untested
2012-04-04math: fix x86 asin accuracynsz2-5/+6
use (1-x)*(1+x) instead of (1-x*x) in asin.s the later can be inaccurate with upward rounding when x is close to 1
2012-03-29math: minor cleanups in ceil and floornsz5-10/+7
2012-03-29math: remove x86 modf asmnsz4-111/+0
the int part was wrong when -1 < x <= -0 (+0.0 instead of -0.0) and the size and performace gain of the asm version was negligible
2012-03-29math: rewrite modf.c and clean up modff.cnsz2-72/+45
cleaner implementation with unions and unsigned arithmetic
2012-03-28math: fix modfl.c bugnsz1-1/+1
modfl(+-inf) was wrong on ld80 because the explicit msb was not taken into account during inf vs nan check
2012-03-27math: fix a regression in powl and do some cleanupsnsz1-12/+11
previously a division was accidentally turned into integer div (w = -i/NXT;) instead of long double div (w = -i; w /= NXT;)
2012-03-27math: add dummy tgamma and tgammaf implementationsnsz2-0/+32
2012-03-27math: remove comment about aliasing lgamma as gammansz3-8/+4
It is probably not worth supporting gamma. (it was already deprecated in 4.3BSD)
2012-03-27math: fix typo in i386 remquof and remquol asmnsz1-5/+5
(fldl instruction was used instead of flds and fldt)
2012-03-23Merge branch 'master' of git://git.etalabs.net/muslnsz2-0/+87
2012-03-23asm for hypot and hypotfRich Felker2-0/+87
special care is made to avoid any inexact computations when either arg is zero (in which case the exact absolute value of the other arg should be returned) and to support the special condition that hypot(±inf,nan) yields inf. hypotl is not yet implemented since avoiding overflow is nontrivial.
2012-03-23minor rintl.c fix: remove unsupported ldbl format messagensz1-2/+0
2012-03-23fix tgammal: don't set the signgam globalnsz1-13/+6
(tgamma must be thread-safe, signgam is for lgamma* functions)
2012-03-22acos.s fix: use the formula acos(x) = atan2(sqrt(1-x),sqrt(1+x))nsz2-6/+2
the old formula atan2(1,sqrt((1+x)/(1-x))) was faster but could give nan result at x=1 when the rounding mode is FE_DOWNWARD (so 1-1 == -0 and 2/-0 == -inf), the new formula gives -0 at x=+-1 with downward rounding.
2012-03-20x86_64 math asm, long double functions onlyRich Felker17-0/+239
this has not been tested heavily, but it's known to at least assemble and run in basic usage cases. it's nearly identical to the corresponding i386 code, and thus expected to be just as correct or just as incorrect.
2012-03-20nearbyint optimization (only clear inexact when necessary)nsz3-19/+29
old code saved/restored the fenv (the new code is only as slow as that when inexact is not set before the call, but some other flag is set and the rounding is inexact, which is rare) before: bench_nearbyint_exact 5000000 N 261 ns/op bench_nearbyint_inexact_set 5000000 N 262 ns/op bench_nearbyint_inexact_unset 5000000 N 261 ns/op after: bench_nearbyint_exact 10000000 N 94.99 ns/op bench_nearbyint_inexact_set 25000000 N 65.81 ns/op bench_nearbyint_inexact_unset 10000000 N 94.97 ns/op
2012-03-20remove a fixme commentnsz3-3/+2
2012-03-20clean up pow.c and powf.cnsz2-57/+43
fix comments about special cases