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

bigfloat transcendentials don't work on julia 1.11

Open j-fu opened this issue 10 months ago • 2 comments

Hi, thanks for the package! It seems that the connection with BigFloat does not work on Julia 1.11:

The MWE

using MultiFloats
MultiFloats.use_bigfloat_transcendentals()
x::Float64x2=10
log10(x)

works for Julia 1.10, but on 1.11 it gives

ERROR: MethodError: no method matching _precision_with_base_2(::Type{MultiFloat{Float64, 2}})
The function `_precision_with_base_2` exists, but no method is defined for this combination of argument types.

Closest candidates are:
_precision_with_base_2(::BigFloat)
@ Base mpfr.jl:957
_precision_with_base_2(::Type{BigFloat})
@ Base mpfr.jl:962
_precision_with_base_2(::Type{Float64})
@ Base float.jl:872
...

Stacktrace:
[1] _precision(x::Type, base::Int64)
@ Base ./float.jl:875
[2] precision(::Type{MultiFloat{Float64, 2}}; base::Int64)
@ Base ./float.jl:878
[3] precision(::Type{MultiFloat{Float64, 2}})
@ Base ./float.jl:878
[4] log10(x::MultiFloat{Float64, 2})
@ MultiFloats ~/.julia/packages/MultiFloats/JtImH/src/MultiFloats.jl:1465
[5] top-level scope
@ REPL[10]:1

j-fu avatar Feb 20 '25 22:02 j-fu

Hey @j-fu, thanks for your interest in MultiFloats.jl! This issue occurs because the Julia authors have once again changed the way that Base.precision(::Type{T}) is internally implemented in Julia 1.11, with no mention in the v1.11 release notes. I find it quite annoying that these changes occur without warning, but for the time being, you can use the following patch to restore the old functionality:

using MultiFloats

@inline Base.precision(::Type{MultiFloat{T,N}}) where {T,N} =
    N * precision(T) + (N - 1) # implicit bits of precision between limbs

After issuing this definition, MultiFloats.use_bigfloat_transcendentals() and log10(::MultiFloat) should work just fine. I am currently working on a new major release MultiFloats.jl v3.0 that will fix this and several other issues, notably #42.

dzhang314 avatar Feb 20 '25 23:02 dzhang314

Thanks! This works now. I also had to define Base.:^ and Base.round. But that may be something after that PR is finished. I put this repo on watch...

j-fu avatar Feb 22 '25 20:02 j-fu

Finding this issue took me a while but solves my log issue. On 1.11.6.

NilsWildt avatar Aug 05 '25 14:08 NilsWildt