Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,11 @@ Floating point manipulation functions

.. function:: frexp(x)

Return the mantissa and exponent of *x* as the pair ``(m, e)``. *m* is a float
and *e* is an integer such that ``x == m * 2**e`` exactly. If *x* is zero,
returns ``(0.0, 0)``, otherwise ``0.5 <= abs(m) < 1``. This is used to "pick
apart" the internal representation of a float in a portable way.
Return the mantissa and exponent of *x* as the pair ``(m, e)``. *m* is a
float and *e* is an integer such that ``x == m * 2**e`` exactly. If *x*
Comment thread
skirpichev marked this conversation as resolved.
Outdated
is a finite nonzero number, then ``0.5 <= abs(m) < 1.0``. Else, returns
``(x, 0)``. This is used to "pick apart" the internal representation of
a float in a portable way.

Note that :func:`frexp` has a different call/return pattern
than its C equivalents: it takes a single argument and return a pair of
Expand Down
5 changes: 3 additions & 2 deletions Modules/clinic/mathmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1439,12 +1439,13 @@ math.frexp
Return the mantissa and exponent of x, as pair (m, e).

m is a float and e is an int, such that x = m * 2.**e.
If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.
If x is a finite nonzero number, then 0.5 <= abs(m) < 1.0.
Else, e is zero and m is x.
[clinic start generated code]*/

static PyObject *
math_frexp_impl(PyObject *module, double x)
/*[clinic end generated code: output=03e30d252a15ad4a input=96251c9e208bc6e9]*/
/*[clinic end generated code: output=03e30d252a15ad4a input=49202d05c5d2c699]*/
{
int i;
/* deal with special cases directly, to sidestep platform
Expand Down
Loading