logf(3)

logf3

Logarithm functions

Part of log(3).

Usage

#include <math.h>

double

log(double x);

float

logf(float x);

long double

logl(long double x);

double

log10(double x);

float

log10f(float x);

long double

log10l(long double x);

double

log2(double x);

float

log2f(float x);

long double

log2l(long double x);

double

log1p(double x);

float

log1pf(float x);

long double

log1pl(long double x);

Library

Math Library (libm, -lm)

Overview

The log(), logf(), and logl() functions compute the natural logarithm of x.

The log10(), log10f(), and log10l() functions compute the logarithm base 10 of x, while log2(), log2f(), and log2l() compute the logarithm base 2 of x.

The log1p(), log1pf(), and log1pl() functions compute the natural logarithm of 1 + x. Computing the natural logarithm as log1p(x) is more accurate than computing it as log(1 + x) when x is close to zero.

Return values

These functions return the requested logarithm; the logarithm of 1 is +0. An attempt to take the logarithm of 0 results in a divide-by-zero exception, and - is returned. Otherwise, attempting to take the logarithm of a negative number results in an invalid exception and a return value of .

Releases

83 releases since FreeBSD 2.2.2-RELEASE; the text changed 46 times.

  1. 2.2.2–2.2.8
  2. 2.2.9
  3. 3.0–3.2
  4. 3.3
  5. 3.4
  6. 3.5–3.5.1
  7. 4.0–4.2
  8. 4.3
  9. 4.4
  10. 4.5–4.11
  11. 5.0–5.2.1
  12. 5.3
  13. 5.4–5.5
  14. 6.0–6.2
  15. 6.3
  16. 6.4
  17. 7.0
  18. 7.1
  19. 7.2
  20. 7.3
  21. 7.4
  22. 8.0
  23. 8.1
  24. 8.2
  25. 8.3
  26. 8.4
  27. 9.0
  28. 9.1
  29. 9.2
  30. 9.3
  31. 10.0
  32. 10.1
  33. 10.2
  34. 10.3
  35. 10.4
  36. 11.0
  37. 11.1
  38. 11.2
  39. 11.3
  40. 11.4
  41. 12.0
  42. 12.1
  43. 12.2
  44. 12.3
  45. 12.4
  46. 13.0–13.2
  47. 13.3–16.0

Standards

The log(), logf(), logl(), log10(), log10f(), log10l(), log2(), log2f(), log2l(), log1p(), log1pf(), and log1pl() functions conform to ISO/IEC 9899:1999 (“ISO C99”).

History

The log() function first appeared in Version 1 AT&T UNIX; log10() in Version 7 AT&T UNIX; log1p() in 4.3BSD.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.