Skip to content

Commit

Permalink
correct forced_sign_bit handling for nans
Browse files Browse the repository at this point in the history
  • Loading branch information
tybug committed Dec 9, 2023
1 parent f52c198 commit 0f0ebcc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hypothesis-python/src/hypothesis/internal/conjecture/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,9 @@ def _draw_float(
Helper for draw_float which draws a random 64-bit float.
"""
if forced is not None:
forced_sign_bit = int(sign_aware_lte(forced, -0.0))
# sign_aware_lte(forced, -0.0) does not correctly handle the
# math.nan case here.
forced_sign_bit = math.copysign(1, forced) == -1

self._cd.start_example(DRAW_FLOAT_LABEL)
try:
Expand Down

0 comments on commit 0f0ebcc

Please sign in to comment.