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

Missing methods in conversion to Integer #20

Closed
jishnub opened this issue Apr 20, 2021 · 1 comment
Closed

Missing methods in conversion to Integer #20

jishnub opened this issue Apr 20, 2021 · 1 comment

Comments

@jishnub
Copy link

jishnub commented Apr 20, 2021

julia> Int(Float64x4(3.0))
ERROR: MethodError: no method matching Int64(::MultiFloat{Float64, 4})
Closest candidates are:
  (::Type{T})(::T) where T<:Number at boot.jl:760
  (::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50
  (::Type{T})(::BigInt) where T<:Union{Int128, Int16, Int32, Int64, Int8} at gmp.jl:356
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[37]:1

julia> Integer(Float64x4(3.0))
ERROR: MethodError: no method matching Integer(::MultiFloat{Float64, 4})
Closest candidates are:
  (::Type{T})(::T) where T<:Number at boot.jl:760
  (::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50
  (::Type{T})(::Base.TwicePrecision) where T<:Number at twiceprecision.jl:243
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[38]:1

It would be nice for these to work to easily switch between Float64 and MultiFloats.

@dzhang314
Copy link
Owner

Hey @jishnub! Thanks for your interest in MultiFloats.jl, and sorry I never got around to looking at this issue years ago.

I've added a conversion to Integer that goes through BigFloat in commit 7eb21d6. Is this sufficient for your purposes? It might be possible to get a faster version that doesn't go through BigFloat, but I don't really understand the use-case of conversion to Integer when it only works for a vanishingly small fraction of inputs.

If this stopgap solution is insufficient, please feel free to reopen this issue.

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

No branches or pull requests

2 participants