Commit Graph

19 Commits

Author SHA1 Message Date
Rich Felker 98c9af5001 fix definitions of FP_ILOGB constants
two issues: (1) the type was wrong (unsigned instead of signed int),
and (2) the value of FP_ILOGBNAN should be INT_MIN rather than INT_MAX
to match the ABI. this is also much more useful since INT_MAX
corresponds to a valid input (infinity). the standard would allow us
to set FP_ILOGB0 to -INT_MAX instead of INT_MIN, which would give us
distinct values for ilogb(0) and ilogb(NAN), but the benefit seems way
too small to justify ignoring the ABI.

note that the macro is just a "portable" (to any twos complement
system where signed and unsigned int have the same width) way to write
INT_MIN without needing limits.h. it's valid to use this method since
these macros are not required to work in #if directives.
2012-05-05 22:22:46 -04:00
Rich Felker a917c03706 support alternate glibc name pow10 for exp10 2012-05-01 00:07:37 -04:00
Rich Felker f681975577 first try at writing an efficient and "correct" exp10
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-30 03:26:53 -04:00
Rich Felker ed0e3a357e fix incorrect macro name for MATH_ERREXCEPT in math.h 2012-04-18 11:41:04 -04:00
Rich Felker 4dbd94112f optimize signbit macro 2012-03-30 23:41:43 -04:00
Rich Felker 93a18a15e4 make math.h more c++-friendly 2012-03-30 23:33:00 -04:00
Rich Felker 8e092217dd move nonstandard gamma() etc. to _GNU_SOURCE only
it's not even provided in the library at the moment, but could easily
be provided with weak aliases if desired.
2012-03-17 21:48:48 -04:00
Rich Felker 65db6bf5ea c++ seems to want some casts in the float representation-access macros 2012-03-17 21:40:10 -04:00
nsz 40305f74bd in math.h make lgamma_r and non-double bessel _GNU_SOURCE only
long double and float bessel functions are no longer xsi extensions
2012-03-15 09:29:53 +01:00
nsz 0144b45b71 efficient sincos based on sin and cos 2012-03-15 08:17:28 +01:00
Rich Felker b69f695ace first commit of the new libm!
thanks to the hard work of Szabolcs Nagy (nsz), identifying the best
(from correctness and license standpoint) implementations from freebsd
and openbsd and cleaning them up! musl should now fully support c99
float and long double math functions, and has near-complete complex
math support. tgmath should also work (fully on gcc-compatible
compilers, and mostly on any c99 compiler).

based largely on commit 0376d44a890fea261506f1fc63833e7a686dca19 from
nsz's libm git repo, with some additions (dummy versions of a few
missing long double complex functions, etc.) by me.

various cleanups still need to be made, including re-adding (if
they're correct) some asm functions that were dropped.
2012-03-13 01:17:53 -04:00
Rich Felker 405ce58dcf fix nan/infinity macros in math.h, etc.
the previous version not only failed to work in c++, but also failed
to produce constant expressions, making the macros useless as
initializers for objects of static storage duration.

gcc 3.3 and later have builtins for these, which sadly seem to be the
most "portable" solution. the alternative definitions produce
exceptions (for NAN) and compiler warnings (for INFINITY) on newer
versions of gcc.
2012-03-02 22:35:37 -05:00
Rich Felker 9fcecd7b34 typo in math.h c version check 2012-03-02 11:38:39 -05:00
Rich Felker db3e78cee5 make math.h compatibe with c89 2012-03-02 00:36:26 -05:00
Rich Felker 414a4cdebc add float_t and double_t to math.h 2012-02-15 21:47:55 -05:00
Rich Felker 3ed8c9f2df fix all missing instances of __cplusplus checks/extern "C" in headers
patch by Arvid Picciani (aep)
2011-11-10 20:40:06 -05:00
Rich Felker e0037efc12 isgreater etc. relation macros for math.h 2011-06-08 16:33:04 -04:00
Rich Felker 74eea628cf extensive header cleanup for standards conformance & correctness
thanks to Peter Mazinger (psm) for pointing many of these issues out
and submitting a patch on which this commit is loosely based
2011-02-14 18:41:25 -05:00
Rich Felker 0b44a0315b initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00