Skip to content
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

A much simpler and much faster classify-ival-periodic #23

Merged
merged 3 commits into from
Mar 17, 2024

Conversation

pavpanchekha
Copy link
Contributor

The core logic is this:

  • Values with exponent < 0 are < 1 and therefore are near-0
  • Values with ulp > 0 have minimum difference of > 1 and therefore are too wide
  • Otherwise, range-reduce

This isn't maximally precise, but points right on the boundary should be rare anyway.

@pavpanchekha pavpanchekha requested a review from AYadrov March 17, 2024 21:01
@pavpanchekha pavpanchekha merged commit ccdea73 into main Mar 17, 2024
1 check passed
@pavpanchekha pavpanchekha deleted the simpler-classify-ival branch March 17, 2024 21:19
(define hi-exp (+ hi-ulp (bigfloat-precision xhi)))
(cond
[(and (not (bfinfinite? xlo)) (not (bfinfinite? xhi))
(< lo-exp 0) (< hi-exp 0)) 'near-0]
Copy link
Contributor

Choose a reason for hiding this comment

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

We may have to add (bfnan?) conditions, because exponent of +nan.bf is -2147483646 - which can be considered as 'near-0 case. Another value I am thinking of is: min.bf = (bf "-2.382564904887951073216169781732674520415e-323228497"), the exponent is equal to -1073741823.
We maybe want check whether lo-exp < 1 = xlo < 1.bf, depends whether we want to classify values closer to 1.bf as 'near-0 as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, ok. I don't know if we need to deal with +nan.bf. It shouldn't be possible to have +nan.bf as the endpoint of an interval unless it's the illegal interval, in which case we can special-case that.

I think min.bf should be handled fine, right? It's exponent is small, so it'll be near-0, which I think is fine?

Comparing the exp to 1 instead of 0 is fine but would require reasoning about the periodicity. I imagine it doesn't actually matter that much: since these values are small, the precision we ultimately choose for the range reduction will also be small, and it's only one binade.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I see, min.bf is not a problem.
By the way, that's impressive how this implementation fits Herbie

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.

2 participants