about summary refs log tree commit diff
path: root/src/math
Commit message (Collapse)AuthorAgeFilesLines
* math: use float constants in exp10f.cSzabolcs Nagy2012-11-181-1/+1
| | | | use the 'f' suffix when a float constant is not representable
* math: expl.c cleanupSzabolcs Nagy2012-11-181-24/+19
| | | | raise overflow and underflow when necessary, fix various comments.
* math: expf.c cleanupSzabolcs Nagy2012-11-182-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.
* math: cleanup exp2.c exp2f.c and exp2l.cSzabolcs Nagy2012-11-173-86/+56
| | | | | | * old code relied on sign extension on right shift * exp2l ld64 wrapper was wrong * use scalbn instead of bithacks
* math: exp.c clean upSzabolcs Nagy2012-11-171-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.
* math: ld80 invtrig cleanupsSzabolcs Nagy2012-11-148-110/+87
| | | | keeping only commonly used data in invtrigl
* math: simplify hypot and hypotf using scalbnSzabolcs Nagy2012-11-132-11/+4
| | | | | this also fixes overflow/underflow raising and excess precision issues (as those are handled well in scalbn)
* math: use '#pragma STDC FENV_ACCESS ON' when fenv is accessedSzabolcs Nagy2012-11-139-0/+10
|
* math: excess precision fix modf, modff, scalbn, scalbnfSzabolcs Nagy2012-11-134-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)
* math: fix scalbn and scalbnf on overflow/underflowSzabolcs Nagy2012-11-132-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)
* math: fix nextafter and nexttoward on maxdbl and maxflt inputSzabolcs Nagy2012-11-134-4/+4
| | | | | old code (return x+x;) returns correct value and raises correct flags only if the result is stored as double (or float)
* math: raise flags in logl.c on <= 0 argumentsSzabolcs Nagy2012-11-132-9/+3
|
* math: fix logb*.c exceptions now that ilogb raises invalidSzabolcs Nagy2012-11-133-25/+17
|
* math: raise flags in log2l.c on <= 0 arguments, and fix volatileSzabolcs Nagy2012-11-131-8/+3
|
* math: raise exception flags in log1pl.c on <= -1 argumentsSzabolcs Nagy2012-11-131-7/+2
|
* math: raise invalid flag in ilogb*.c on +-0, +-inf and nanSzabolcs Nagy2012-11-123-6/+18
|
* math: fix exception behaviour of expm1l.c on inf and nanSzabolcs Nagy2012-11-121-13/+7
|
* math: fix long double constants in exp10l.cSzabolcs Nagy2012-11-121-2/+2
|
* Merge remote-tracking branch 'nsz/exp'Rich Felker2012-08-132-40/+35
|\
| * math: fix exp.s on i386 and x86_64 so the exception flags are correctnsz2012-08-082-40/+35
| | | | | | | | exp(inf), exp(-inf), exp(nan) used to raise wrong flags
* | remove significandlRich Felker2012-08-131-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...
* | add significand[fl] math functionsRich Felker2012-08-133-0/+21
|/
* fix missing prototype and simplify sincosl on ld64 archsRich Felker2012-07-021-4/+2
|
* fix invalid implicit pointer conversion in ld64 modflRich Felker2012-07-021-1/+1
|
* math: fix fma bug on x86 (found by Bruno Haible with gnulib)nsz2012-06-201-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.
* support ld80 pseudo-denormal invalid bit patterns; treat them as nanRich Felker2012-06-201-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...
* use fistpll mnemonic instead of fistpq (more widely supported) on x86_64 tooRich Felker2012-06-021-1/+1
| | | | | this was fixed previously on i386 but the corresponding code on x86_64 was missed.
* math: fix remquo.c when x==-y and a subnormal remainder bug as wellnsz2012-05-083-5/+8
| | | | | backported fix from freebsd: http://svnweb.FreeBSD.org/base?view=revision&revision=233973
* some assemblers don't like fistpq; use the alt. mnemonic fistpllRich Felker2012-05-073-3/+3
|
* add FORCE_EVAL macro to evaluate float expr for their side effectnsz2012-05-065-24/+12
| | | | | updated nextafter* to use FORCE_EVAL, it can be used in many other places in the math code to improve readability.
* fix unused variable warnings in new nextafter/nexttoward codeRich Felker2012-05-065-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).
* math: nextafter and nexttoward cleanupnsz2012-05-065-291/+176
| | | | | make nexttoward, nexttowardf independent of long double representation. fix nextafterl: it did not raise underflow flag when the result was 0.
* math: change the formula used for acos.snsz2012-05-052-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)
* support alternate glibc name pow10 for exp10Rich Felker2012-05-013-0/+9
|
* add C stub for sqrtl (already implemented in asm on i386 and x86_64)Rich Felker2012-04-301-0/+9
|
* first try at writing an efficient and "correct" exp10Rich Felker2012-04-303-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.
* fix typo in the x86_64 rounding asmRich Felker2012-04-294-4/+4
|
* new math asm (abs/rounding) for x86_64Rich Felker2012-04-296-0/+36
| | | | untested
* math: fix x86 asin accuracynsz2012-04-042-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
* math: minor cleanups in ceil and floornsz2012-03-295-10/+7
|
* math: remove x86 modf asmnsz2012-03-294-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
* math: rewrite modf.c and clean up modff.cnsz2012-03-292-72/+45
| | | | cleaner implementation with unions and unsigned arithmetic
* math: fix modfl.c bugnsz2012-03-281-1/+1
| | | | | modfl(+-inf) was wrong on ld80 because the explicit msb was not taken into account during inf vs nan check
* math: fix a regression in powl and do some cleanupsnsz2012-03-271-12/+11
| | | | | previously a division was accidentally turned into integer div (w = -i/NXT;) instead of long double div (w = -i; w /= NXT;)
* math: add dummy tgamma and tgammaf implementationsnsz2012-03-272-0/+32
|
* math: remove comment about aliasing lgamma as gammansz2012-03-273-8/+4
| | | | | It is probably not worth supporting gamma. (it was already deprecated in 4.3BSD)
* math: fix typo in i386 remquof and remquol asmnsz2012-03-271-5/+5
| | | | (fldl instruction was used instead of flds and fldt)
* Merge branch 'master' of git://git.etalabs.net/muslnsz2012-03-232-0/+87
|\
| * asm for hypot and hypotfRich Felker2012-03-232-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.
* | minor rintl.c fix: remove unsupported ldbl format messagensz2012-03-231-2/+0
| |