Skip to content

Conversation

@samth
Copy link
Member

@samth samth commented Jun 25, 2024

Related to #1042

samth added 4 commits June 25, 2024 15:53
For example, (- (expt 10 309) +inf.0) is -inf.0 but
(- (->fl (expt 10 309)) +inf.0) is nan.0.

Related to racket#1042.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resyntax analyzed 2 files in this pull request and found no issues.

samth pushed a commit to samth/typed-racket that referenced this pull request Jan 23, 2026
This commit addresses correctness issues in float optimization:

1. Fix type of (/ 0.0): Changed the division type from
   (-> -NonPosReal -NonPosReal) to (-> -NegReal -NonPosReal) to
   correctly handle cases like (/ (min 0.0 0)) which returns +inf.0.

2. Avoid optimizing float exprs when conversion can change result:
   Added safe-to-convert? check to prevent converting large exact
   numbers to infinity before operations. For example,
   (- (expt 10 309) +inf.0) should yield -inf.0, but premature
   conversion to float would give +nan.0.

3. Added tests for these fixes plus a test for make-polar with NaN
   arguments to ensure complex NaN is preserved.

Based on PR racket#1381. Fixes racket#1042.

https://claude.ai/code/session_01UKyzYRFQ9Zm7KsDor34VoY
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