Closed
Description
Comparisons seem to involve BigFloat
conversions, which makes them way slower than Base.Irrational
julia> @btime 3.0 ≤ pi
1.287 ns (0 allocations: 0 bytes)
true
julia> @btime 3.0 ≤ invsqrt2
471.291 ns (8 allocations: 352 bytes)
false
This seems to be causing JuliaMath/SpecialFunctions.jl#484
In contrast, it's way faster to compare after conversion of the irrational value to floating point:
julia> @btime 3.0 ≤ oftype(3.0, invsqrt2)
1.287 ns (0 allocations: 0 bytes)
false
I'm guessing this is some type of pedantry where you want to check that the exact rational floating-point value is ≤
the exact irrational value? Even so, can't you just compare to the RoundDown
conversion?
(Why didn't you just use Base.Irrational
, anyway?)
Metadata
Metadata
Assignees
Labels
No labels