问题
What are the available portable implementations of the C99 long double math library functions (expl
, cosl
, logl
, etc.), if any? I've looked in fdlibm (Sun-based), NetBSD (UCB-based), etc. sources and not seen them.
回答1:
You should be able to see it in the Sun-based libraries (used in pretty much all the open C libraries I am aware of, including glibc and FreeBSD one).
I generally prefer BSD code for math code (more readable IMO). See here for 80-bits (Intel) long double format. For a given function, different implementation/architectures may be in different directories.
One thing to realize is that long double is not standardized (more exactly, only since the 2008 rev of IEEE754, which is not really implemented in most common CPU yet). Which means each CPU requires a different implementation for a lot of stuff (IA32, AMD64, PPC, Alpha, Sparc are all different in that aspect...).
回答2:
Try the Cephes Mathematical Library.
来源:https://stackoverflow.com/questions/5945129/long-double-math-library-implementations