Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BUG: Fix rounding of denormals in double and float to half casts. #12845

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
Jan 24, 2019

Conversation

charris
Copy link
Member

@charris charris commented Jan 24, 2019

Backport of #12722

  • BUG: Fix rounding of denormals in double and float to half casts

Previously the significand was shifted right to align denormals of
different magnitude. This loses some bits that can make a difference
for rounding. This is fixed:

  1. For floats, by inspecting the original last bits when this may
    make a difference (should happen rarely)
  2. For doubles by shifting the bits left to align the denromals and
    thus not lose the lowest orginal bits.
  • TST: Test half denormal rounding

The test assumes that half to even is active, if this is ever
changed or allowed to change, the test will fail.

  • Fixup: Fixup for halffloat.c

The one code path cannot be used. The other must have been a typo, but
is a valid bug, a new test for it in the next commit.

  • TST: half casting lower bits are not lost for denormal results

The first test only tested the off by one, this one specifically tests
that all bits are used to decide if "round to nearest even" should
be used, in the example of rounding towards 0.

  • TST: Test not just denormals but all positive finite float16s

  • DOC: Add lots of comments and add a short release note.

…umpy#12722)

* BUG: Fix rounding of denormals in double and float to half casts

Previously the significand was shifted right to align denormals of
different magnitude. This loses some bits that can make a difference
for rounding. This is fixed:
 1. For floats, by inspecting the original last bits when this may
    make a difference (should happen rarely)
 2. For doubles by shifting the bits left to align the denromals and
    thus not lose the lowest orginal bits.

* TST: Test half denormal rounding

The test assumes that half to even is active, if this is ever
changed or allowed to change, the test will fail.

* Fixup: Fixup for halffloat.c

The one code path cannot be used. The other must have been a typo, but
is a valid bug, a new test for it in the next commit.

* TST: half casting lower bits are not lost for denormal results

The first test only tested the off by one, this one specifically tests
that all bits are used to decide if "round to nearest even" should
be used, in the example of rounding towards 0.

* TST: Test not just denormals but all positive finite float16s

* DOC: Add lots of comments and add a short release note.
@charris charris added this to the 1.16.1 release milestone Jan 24, 2019
@charris charris merged commit 531c6be into numpy:maintenance/1.16.x Jan 24, 2019
@charris charris deleted the backport-12722 branch January 24, 2019 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.