Skip to content

Commit

Permalink
Fix BigFloat in Julia v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Dec 13, 2019
1 parent f4f12f5 commit 2175bc4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/bigfloat.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
mutability(::Type{BigFloat}) = IsMutable()
mutable_copy(x::BigFloat) = deepcopy(x)

@static if VERSION >= v"1.1.0-DEV.683"
const MPFRRoundingMode = Base.MPFR.MPFRRoundingMode
else
const MPFRRoundingMode = Int32
end

# zero
promote_operation(::typeof(zero), ::Type{BigFloat}) = BigFloat
function _set_si!(x::BigFloat, value)
ccall((:mpfr_set_si, :libmpfr), Int32, (Ref{BigFloat}, Clong, Base.MPFR.MPFRRoundingMode), x, value, Base.MPFR.ROUNDING_MODE[])
ccall((:mpfr_set_si, :libmpfr), Int32, (Ref{BigFloat}, Clong, MPFRRoundingMode), x, value, Base.MPFR.ROUNDING_MODE[])
return x
end
mutable_operate!(::typeof(zero), x::BigFloat) = _set_si!(x, 0)
Expand All @@ -16,7 +22,7 @@ mutable_operate!(::typeof(one), x::BigFloat) = _set_si!(x, 1)
# +
promote_operation(::typeof(+), ::Vararg{Type{BigFloat}, N}) where {N} = BigFloat
function mutable_operate_to!(output::BigFloat, ::typeof(+), a::BigFloat, b::BigFloat)
ccall((:mpfr_add, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, Base.MPFR.MPFRRoundingMode), output, a, b, Base.MPFR.ROUNDING_MODE[])
ccall((:mpfr_add, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, MPFRRoundingMode), output, a, b, Base.MPFR.ROUNDING_MODE[])
return output
end
#function mutable_operate_to!(output::BigFloat, op::typeof(+), a::BigFloat, b::LinearAlgebra.UniformScaling)
Expand All @@ -26,7 +32,7 @@ end
# *
promote_operation(::typeof(*), ::Vararg{Type{BigFloat}, N}) where {N} = BigFloat
function mutable_operate_to!(output::BigFloat, ::typeof(*), a::BigFloat, b::BigFloat)
ccall((:mpfr_mul, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, Base.MPFR.MPFRRoundingMode), output, a, b, Base.MPFR.ROUNDING_MODE[])
ccall((:mpfr_mul, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, MPFRRoundingMode), output, a, b, Base.MPFR.ROUNDING_MODE[])
return output
end

Expand Down

0 comments on commit 2175bc4

Please sign in to comment.