Skip to content

Fix Modf leaving a reused Infinity or NaN unchanged - #158

Open
SashaMIT wants to merge 1 commit into
cockroachdb:masterfrom
SashaMIT:fix/modf-resets-form
Open

SashaMIT wants to merge 1 commit into
cockroachdb:masterfrom
SashaMIT:fix/modf-resets-form

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 2, 2026 •

Copy link
Copy Markdown

Summary

Modf wrote the coefficient, exponent, and sign of the integral and fractional parts and left Form untouched. A destination that was Infinity or NaN still stringified as that form.

Modf of 1.5 into an Infinity and a NaN returned Infinity and NaN. It now returns 1 and 0.5. A value smaller than 1, such as 0.00001, now has integral part 0 instead of Infinity. An integer such as 20 now has fractional part 0 instead of NaN.

Test plan

  • TestModfResetsNonFiniteDestination failed on tip (integ = Infinity) and passes with the change
  • go test -count=1 . passed

Modf wrote the coefficient of each part and left Form alone, so a
destination that was Infinity or NaN still stringified as that form.
Modf of 1.5 into those values returned Infinity and NaN instead of 1
and 0.5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant