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 โ€” errno is set to EDOM. An invalid floating-point exception (FE_INVALID) is raised.
  • Pole error: x is zero โ€” errno is set to ERANGE. 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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms