log(3)
๐ log(3) โ the natural logarithmic function, bestie ๐
okay so this is log(3) from the Library Functions Manual, and honestly? she's iconic. she's literally the natural log. the way that a logarithm just... undoes an exponent? obsessed. ๐
โจ NAME โจ
log, logf, logl โ natural logarithmic function
๐ LIBRARY ๐
Math library (libm, -lm)
not me reminding you to link -lm because if you don't you'll get undefined reference and you'll be sobbing. it's giving character development. ๐ญ
๐ฆ SYNOPSIS ๐ฆ
#include <math.h>
double log(double x);
float logf(float x);
long double logl(long double x);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
logf(), logl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
yeah those macros are a whole vibe check. copy them exactly, don't freestyle. ๐
๐ธ DESCRIPTION ๐ธ
These functions return the natural logarithm of x.
that's it. that's the whole job. she logs, naturally. โจ
๐ RETURN VALUE ๐
On success, these functions return the natural logarithm of x.
If x is a NaN, a NaN is returned. (NaN in, NaN out, no thoughts head empty. ๐)
If x is 1, the result is +0.
If x is positive infinity, positive infinity is returned. (+inf in, +inf out, they're matching, it's cute. ๐)
If x is zero, then a pole error occurs, and the functions return -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively.
If x is negative (including negative infinity), then a domain error occurs, and a NaN (not a number) is returned.
bestie. negative inputs are NOT it. that's a domain error, that's undefined behaviour territory, that's the math equivalent of texting your ex. ๐ซ
๐ฅ ERRORS ๐ฅ
See math_error(7) for information on how to determine whether an error has occurred when calling these functions.
The following errors can occur:
- Domain error: x is negative โ
errnois set toEDOM. An invalid floating-point exception (FE_INVALID) is raised. - Pole error: x is zero โ
errnois set toERANGE. A divide-by-zero floating-point exception (FE_DIVBYZERO) is raised.
so like. if x is negative you get EDOM + FE_INVALID. if x is zero you get ERANGE + FE_DIVBYZERO. write it down, there will be a quiz. ๐
๐ ATTRIBUTES ๐
For an explanation of the terms used in this section, see attributes(7).
- Interface:
log(),logf(),logl()- Attribute: Thread safety
- Value:
MT-Safe
MT-Safe?? we LOVE a thread-safe queen. take her everywhere, she will not betray you. ๐ซถ
โญ STANDARDS โญ
C11, POSIX.1-2008.
๐ HISTORY ๐
C99, POSIX.1-2001.
The variant returning double also conforms to SVr4, 4.3BSD, C89.
she's been around. she's got lore. respect the elders. ๐
๐ BUGS ๐
In glibc 2.5 and earlier, taking the log() of a NaN produces a bogus invalid floating-point (FE_INVALID) exception.
not me finding out the old glibc was just out here raising FE_INVALID for no reason ๐ญ it's giving glitchy. if you're on glibc 2.5 or earlier... bestie why. ๐ฐ๏ธ
๐ SEE ALSO ๐
cbrt(3), clog(3), log10(3), log1p(3), log2(3), sqrt(3)
the whole log-iverse. go read them all, they're all slaying in their own way. ๐
and that's the page!! from Linux man-pages 6.20, dated 2026-02-08, log(3) โ she's natural, she's logarithmic, she's that girl. stan. ๐
โจ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms