summaryrefslogtreecommitdiff
path: root/src/math
AgeCommit message (Collapse)AuthorLines
2012-12-07fix trailing whitespace issues that crept in here and thereRich Felker-1/+1
2012-11-18math: use float constants in exp10f.cSzabolcs Nagy-1/+1
use the 'f' suffix when a float constant is not representable
2012-11-18math: expl.c cleanupSzabolcs Nagy-24/+19
raise overflow and underflow when necessary, fix various comments.
2012-11-18math: expf.c cleanupSzabolcs Nagy-63/+55
similar to exp.c cleanup: use scalbnf, don't return excess precision, drop some optimizatoins. exp.c was changed to be more consistent with expf.c code.
2012-11-17math: cleanup exp2.c exp2f.c and exp2l.cSzabolcs Nagy-86/+56
* old code relied on sign extension on right shift * exp2l ld64 wrapper was wrong * use scalbn instead of bithacks
2012-11-17math: exp.c clean upSzabolcs Nagy-72/+49
overflow and underflow was incorrect when the result was not stored. an optimization for the 0.5*ln2 < |x| < 1.5*ln2 domain was removed. did various cleanups around static constants and made the comments consistent with the code.
2012-11-14math: ld80 invtrig cleanupsSzabolcs Nagy-110/+87
keeping only commonly used data in invtrigl
2012-11-13math: simplify hypot and hypotf using scalbnSzabolcs Nagy-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 Nagy-0/+10
2012-11-13math: excess precision fix modf, modff, scalbn, scalbnfSzabolcs Nagy-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 Nagy-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 Nagy-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 Nagy-9/+3
2012-11-13math: fix logb*.c exceptions now that ilogb raises invalidSzabolcs Nagy-25/+17
2012-11-13math: raise flags in log2l.c on <= 0 arguments, and fix volatileSzabolcs Nagy-8/+3
2012-11-13math: raise exception flags in log1pl.c on <= -1 argumentsSzabolcs Nagy-7/+2
2012-11-12math: raise invalid flag in ilogb*.c on +-0, +-inf and nanSzabolcs Nagy-6/+18
2012-11-12math: fix exception behaviour of expm1l.c on inf and nanSzabolcs Nagy-13/+7
2012-11-12math: fix long double constants in exp10l.cSzabolcs Nagy-2/+2
2012-08-13Merge remote-tracking branch 'nsz/exp'Rich Felker-40/+35
2012-08-13remove significandlRich Felker-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 Felker-0/+21
2012-08-08math: fix exp.s on i386 and x86_64 so the exception flags are correctnsz-40/+35
exp(inf), exp(-inf), exp(nan) used to raise wrong flags
2012-07-02fix missing prototype and simplify sincosl on ld64 archsRich Felker-4/+2
2012-07-02fix invalid implicit pointer conversion in ld64 modflRich Felker-1/+1
2012-06-20math: fix fma bug on x86 (found by Bruno Haible with gnulib)nsz-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 Felker-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 Felker-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 wellnsz-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 Felker-3/+3
2012-05-06add FORCE_EVAL macro to evaluate float expr for their side effectnsz-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 Felker-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 cleanupnsz-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.snsz-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 Felker-0/+9
2012-04-30add C stub for sqrtl (already implemented in asm on i386 and x86_64)Rich Felker-0/+9
2012-04-30first try at writing an efficient and "correct" exp10Rich Felker-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 Felker-4/+4
2012-04-29new math asm (abs/rounding) for x86_64Rich Felker-0/+36
untested
2012-04-04math: fix x86 asin accuracynsz-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 floornsz-10/+7
2012-03-29math: remove x86 modf asmnsz-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.cnsz-72/+45
cleaner implementation with unions and unsigned arithmetic
2012-03-28math: fix modfl.c bugnsz-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 cleanupsnsz-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 implementationsnsz-0/+32
2012-03-27math: remove comment about aliasing lgamma as gammansz-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 asmnsz-5/+5
(fldl instruction was used instead of flds and fldt)
2012-03-23Merge branch 'master' of git://git.etalabs.net/muslnsz-0/+87
2012-03-23asm for hypot and hypotfRich Felker-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.