MultiFloats.jl icon indicating copy to clipboard operation
MultiFloats.jl copied to clipboard

Promotion of Irrationals

Open jishnub opened this issue 3 years ago • 2 comments

julia> pi * Float64x4(2)
ERROR: MethodError: Cannot `convert` an object of type Irrational{:π} to an object of type NTuple{4, Float64}

Perhaps there might be a way to convert these to BigFloat and then to MultiFloats

julia> 2Float64x4(big(pi))
6.283185307179586476925286766559005768394338798750211641949889184604

jishnub avatar Apr 20 '21 07:04 jishnub

Hey @jishnub , good catch! I totally overlooked this in my own testing. You're right, a conversion to BigFloat (with the precision set to the appropriate level) and then to MultiFloat is absolutely the right way to do it. I'll get this implemented in the next version of MultiFloats.jl.

dzhang314 avatar Apr 29 '21 03:04 dzhang314

I hit the same problem. A fix could be something like:

function MultiFloat{T,N}(x::Union{Rational{S},Irrational{S}}) where {S,T,N}
    MultiFloat{T,N}(BigFloat(x; precision = precision(MultiFloat{T,N})))
end

then I get

Float64x2(π)
3.141592653589793238462643383279506

goulart-paul avatar Oct 03 '23 18:10 goulart-paul

Hey everyone! It's been ages since I last looked at MultiFloats.jl, but I've finally pushed a fix for this in commit 02091e0.

dzhang314 avatar Sep 08 '24 22:09 dzhang314