Skip to content

Commit b2b230f

Browse files
check version inside Float128(::BigInt)
1 parent 67c02de commit b2b230f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Quadmath.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,18 @@ end
354354

355355
function BigInt(x::Float128)
356356
!isinteger(x) && throw(InexactError(:BigInt, x))
357-
BigInt(BigFloat(x, precision=precision(Float128)))
357+
358+
@static if VERSION < v"1.1"
359+
y = setprecision(BigFloat, max(precision, precision(Float128))) do
360+
BigFloat()
361+
end
362+
ccall((:mpfr_set, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Int32),
363+
y, x, Base.MPFR.ROUNDING_MODE[])
364+
else
365+
y = BigFloat(x, precision=precision(Float128))
366+
end
367+
368+
return BigInt(y)
358369
end
359370
Float128(x::BigInt) = Float128(BigFloat(x, precision=precision(Float128)))
360371

0 commit comments

Comments
 (0)