As far as I know some math functions are contained in libc, while others are in libm. I've discovered that experimentally:
$ nm --dynamic --defined-only /lib/x86_64-linux-gnu/libm.so.6 | grep -w abs
$ nm --dynamic --defined-only /lib/x86_64-linux-gnu/libc.so.6 | grep -w abs
T abs
Is there a requirement concerning which mathematical functions must be provided by libm? Does libc and libm together provide all the math functions required by C standard?
math.h
. – Birdwatcherabs()
is in stdlib.h, not in math.h. – Ventilator-lm
or its equivalent to get the mathematical functions from the standard C library — macOS is a specific example. Once upon a long time ago, having the library separate was sensible because the same basic hardware might or might not have floating point arithmetic available (Intel 80386 with optional 80387 FPU (floating point unit) for a late example — which also helps date when this was a problem). Nowadays, this is seldom an issue; it would be more sensible to make-lm
optional. The rules in the embedded space are different. – Semanticprintf()
andscanf()
functionality — with and without support for floating point (because the floating point support is quite big, which mattered when your program was limited to 64 KiB). – Semantic