---
name: "logf"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/log/3"
---

# logf(3)

logarithm functions

Part of [log(3)](/log/3.md).

## NAME

**log**, **logf**, **logl**, **log10**, **log10f**, **log10l**, **log2**, **log2f**, **log2l**, **log1p**, **log1pf**, **log1pl** – logarithm functions

## LIBRARY

Math Library (libm, -lm)

## SYNOPSIS

**#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*);

## DESCRIPTION

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 .

## SEE ALSO

[exp(3)](/exp/3.md), [ilogb(3)](/ilogb/3.md), [math(3)](/math/3.md), [pow(3)](/pow/3.md)

## 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.
