8000 MAINT: Fix test_int_from_huge_longdouble on Darwin. by charris · Pull Request #10000 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Fix test_int_from_huge_longdouble on Darwin. #10000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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: 6 additions & 3 deletions numpy/core/src/private/npy_longdouble.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@
} while (0)


/* Heavily derived from PyLong_FromDouble
/*
* Heavily derived from PyLong_FromDouble
* Notably, we can't set the digits directly, so have to shift and or instead.
*/
PyObject *
npy_longdouble_to_PyLong(npy_longdouble ldval)
{
PyObject *v;
PyObject *l_chunk_size;
// number of bits to extract at a time. CPython uses 30, but that's because
// it's tied to the internal long representation
/*
* number of bits to extract at a time. CPython uses 30, but that's because
* it's tied to the internal long representation
*/
const int chunk_size = NPY_BITSOF_LONGLONG;
npy_longdouble frac;
int i, ndig, expo, neg;
Expand Down
9 changes: 5 additions & 4 deletions numpy/core/tests/test_scalarmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,11 @@ def test_int_from_infinite_longdouble___int__(self):

@dec.skipif(np.finfo(np.double) == np.finfo(np.longdouble))
def test_int_from_huge_longdouble(self):
# produce a longdouble that would overflow a double
exp = np.finfo(np.double).maxexp
huge_ld = 1234 * np.longdouble(2) ** exp
huge_i = 1234 * 2 ** exp
# Produce a longdouble that would overflow a double,
# use exponent that avoids bug in Darwin pow function.
exp = np.finfo(np.double).maxexp - 1
huge_ld = 2 * 1234 * np.longdouble(2) ** exp
huge_i = 2 * 1234 * 2 ** exp
assert_(huge_ld != np.inf)
assert_equal(int(huge_ld), huge_i)

Expand Down
0