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

Speed up a..b #34

Closed
dpsanders opened this issue May 24, 2017 · 2 comments
Closed

Speed up a..b #34

dpsanders opened this issue May 24, 2017 · 2 comments

Comments

@dpsanders
Copy link
Member

dpsanders commented May 24, 2017

Don't use complicated conversions -- leave that for @interval.
Just do Interval(prevfloat(a), nextfloat(b)).

But can treat integers exactly:

..(a::Integer, b::Integer) = Interval(a, b)
..(a::Integer, b::Float64) = Interval(a, nextfloat(b))
..(a::Float64, b::Int) = Interval(prevfloat(a), b)

..(a::Float64, b::Float64) = Interval(prevfloat(a), nextfloat(b))

This will take care of most of the useful cases, such as writing 0..\infty.

@dpsanders
Copy link
Member Author

dpsanders commented May 24, 2017

This gives

julia> @format full
6

julia> 0..1
Interval(0.0, 1.0)

julia> 0.0..1.0
Interval(-5.0e-324, 1.0000000000000002)

julia> 0..Interval(0.0, Inf)

@dpsanders
Copy link
Member Author

See PR #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant