diff --git a/base/mpfr.jl b/base/mpfr.jl
index bd1f39532ba3f..d5956e6f493a7 100644
--- a/base/mpfr.jl
+++ b/base/mpfr.jl
@@ -580,6 +580,25 @@ end
 <(x::BigFloat, y::BigFloat) = ccall((:mpfr_less_p, :libmpfr), Int32, (Ptr{BigFloat}, Ptr{BigFloat}), &x, &y) != 0
 >(x::BigFloat, y::BigFloat) = ccall((:mpfr_greater_p, :libmpfr), Int32, (Ptr{BigFloat}, Ptr{BigFloat}), &x, &y) != 0
 
+function ==(i::BigInt, f::BigFloat)
+    !isnan(f) && ccall((:mpfr_cmp_z, :libmpfr), Int32, (Ptr{BigFloat}, Ptr{BigInt}), &f, &i) == 0
+end
+
+==(f::BigFloat, i::BigInt) = i == f
+
+function <(i::BigInt, f::BigFloat)
+    # note: mpfr_cmp_z returns 0 if isnan(f)
+    ccall((:mpfr_cmp_z, :libmpfr), Int32, (Ptr{BigFloat}, Ptr{BigInt}), &f, &i) > 0
+end
+
+function <(f::BigFloat, i::BigInt)
+    # note: mpfr_cmp_z returns 0 if isnan(f)
+    ccall((:mpfr_cmp_z, :libmpfr), Int32, (Ptr{BigFloat}, Ptr{BigInt}), &f, &i) < 0
+end
+
+<=(i::BigInt, f::BigFloat) = !isnan(f) && !(f < i)
+<=(f::BigFloat, i::BigInt) = !isnan(f) && !(i < f)
+
 signbit(x::BigFloat) = ccall((:mpfr_signbit, :libmpfr), Int32, (Ptr{BigFloat},), &x) != 0
 
 function precision(x::BigFloat)
diff --git a/test/mpfr.jl b/test/mpfr.jl
index a10ea3a6fbf6d..54e3c57a126ff 100644
--- a/test/mpfr.jl
+++ b/test/mpfr.jl
@@ -766,3 +766,19 @@ tol = 1e-3
 @test typemax(Int128)  * big(1.0) == convert(BigFloat, typemax(Int128))
 @test typemax(Uint64)  * big(1.0) == big(typemax(Uint64))
 @test typemax(Uint128) * big(1.0) == big(typemax(Uint128))
+
+# issue #3399
+i1 = BigInt(10)^1000
+i2 = BigInt("10000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
+f = BigFloat(10)^1000
+@test i1 != i2
+@test i1 != f
+@test i2 != f
+
+@test f > i1
+@test f > i2
+
+i3 = itrunc(f)
+@test i3 == f
+@test i3+1 > f
+@test i3+1 >= f