| 1 |
'\" t |
| 2 |
.\" Copyright 1995, James R. Van Zandt <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH expm1 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
expm1, expm1f, expm1l \- exponential minus 1 |
| 10 |
.SH LIBRARY |
| 11 |
Math library |
| 12 |
.RI ( libm ,\~ \-lm ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <math.h> |
| 16 |
.P |
| 17 |
.BI "double expm1(double " x ); |
| 18 |
.BI "float expm1f(float " x ); |
| 19 |
.BI "long double expm1l(long double " x ); |
| 20 |
.P |
| 21 |
.fi |
| 22 |
.RS -4 |
| 23 |
Feature Test Macro Requirements for glibc (see |
| 24 |
.BR feature_test_macros (7)): |
| 25 |
.RE |
| 26 |
.P |
| 27 |
.BR expm1 (): |
| 28 |
.nf |
| 29 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 30 |
|| _XOPEN_SOURCE >= 500 |
| 31 |
.\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED |
| 32 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE |
| 33 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 34 |
.fi |
| 35 |
.P |
| 36 |
.BR expm1f (), |
| 37 |
.BR expm1l (): |
| 38 |
.nf |
| 39 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 40 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE |
| 41 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 42 |
.fi |
| 43 |
.SH DESCRIPTION |
| 44 |
These functions return a value equivalent to |
| 45 |
.P |
| 46 |
.nf |
| 47 |
exp(x) \- 1 |
| 48 |
.fi |
| 49 |
.P |
| 50 |
The result is computed in a way that is accurate even if the value of |
| 51 |
.I x |
| 52 |
is near |
| 53 |
zero\[em]a case where |
| 54 |
.I "exp(x) \- 1" |
| 55 |
would be inaccurate due to |
| 56 |
subtraction of two numbers that are nearly equal. |
| 57 |
.SH RETURN VALUE |
| 58 |
On success, these functions return |
| 59 |
.IR "exp(x)\ \-\ 1" . |
| 60 |
.P |
| 61 |
If |
| 62 |
.I x |
| 63 |
is a NaN, |
| 64 |
a NaN is returned. |
| 65 |
.P |
| 66 |
If |
| 67 |
.I x |
| 68 |
is +0 (\-0), |
| 69 |
+0 (\-0) is returned. |
| 70 |
.P |
| 71 |
If |
| 72 |
.I x |
| 73 |
is positive infinity, positive infinity is returned. |
| 74 |
.P |
| 75 |
If |
| 76 |
.I x |
| 77 |
is negative infinity, \-1 is returned. |
| 78 |
.P |
| 79 |
If the result overflows, a range error occurs, |
| 80 |
and the functions return |
| 81 |
.RB \- HUGE_VAL , |
| 82 |
.RB \- HUGE_VALF , |
| 83 |
or |
| 84 |
.RB \- HUGE_VALL , |
| 85 |
respectively. |
| 86 |
.SH ERRORS |
| 87 |
See |
| 88 |
.BR math_error (7) |
| 89 |
for information on how to determine whether an error has occurred |
| 90 |
when calling these functions. |
| 91 |
.P |
| 92 |
The following errors can occur: |
| 93 |
.TP |
| 94 |
Range error, overflow |
| 95 |
.I errno |
| 96 |
is set to |
| 97 |
.B ERANGE |
| 98 |
(but see BUGS). |
| 99 |
An overflow floating-point exception |
| 100 |
.RB ( FE_OVERFLOW ) |
| 101 |
is raised. |
| 102 |
.\" |
| 103 |
.\" POSIX.1 specifies an optional range error (underflow) if |
| 104 |
.\" x is subnormal. glibc does not implement this. |
| 105 |
.SH ATTRIBUTES |
| 106 |
For an explanation of the terms used in this section, see |
| 107 |
.BR attributes (7). |
| 108 |
.TS |
| 109 |
allbox; |
| 110 |
lbx lb lb |
| 111 |
l l l. |
| 112 |
Interface Attribute Value |
| 113 |
T{ |
| 114 |
.na |
| 115 |
.nh |
| 116 |
.BR expm1 (), |
| 117 |
.BR expm1f (), |
| 118 |
.BR expm1l () |
| 119 |
T} Thread safety MT-Safe |
| 120 |
.TE |
| 121 |
.SH STANDARDS |
| 122 |
C11, POSIX.1-2008. |
| 123 |
.SH HISTORY |
| 124 |
C99, POSIX.1-2001. |
| 125 |
BSD. |
| 126 |
.SH BUGS |
| 127 |
Before glibc 2.17, |
| 128 |
.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6778 |
| 129 |
on certain architectures (e.g., x86, but not x86_64) |
| 130 |
.BR expm1 () |
| 131 |
raised a bogus underflow floating-point exception |
| 132 |
for some large negative |
| 133 |
.I x |
| 134 |
values (where the function result approaches \-1). |
| 135 |
.P |
| 136 |
Before approximately glibc 2.11, |
| 137 |
.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6814 |
| 138 |
.\" e.g., expm1(1e5) through expm1(1.00199970127e5), |
| 139 |
.\" but not expm1(1.00199970128e5) and beyond. |
| 140 |
.BR expm1 () |
| 141 |
raised a bogus invalid floating-point exception in addition to the expected |
| 142 |
overflow exception, and returned a NaN instead of positive infinity, |
| 143 |
for some large positive |
| 144 |
.I x |
| 145 |
values. |
| 146 |
.P |
| 147 |
Before glibc 2.11, |
| 148 |
.\" It looks like the fix was in glibc 2.11, or possibly glibc 2.12. |
| 149 |
.\" I have no test system for glibc 2.11, but glibc 2.12 passes. |
| 150 |
.\" From the source (sysdeps/i386/fpu/s_expm1.S) it looks |
| 151 |
.\" like the changes were in glibc 2.11. |
| 152 |
the glibc implementation did not set |
| 153 |
.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6788 |
| 154 |
.I errno |
| 155 |
to |
| 156 |
.B ERANGE |
| 157 |
when a range error occurred. |
| 158 |
.SH SEE ALSO |
| 159 |
.BR exp (3), |
| 160 |
.BR log (3), |
| 161 |
.BR log1p (3) |