From 7d290fb0293c0488abf12d1d68d4569bcbbb1788 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Fri, 12 Feb 2016 13:40:34 -0500 Subject: [PATCH] Add missing method for setrounding --- src/Compat.jl | 15 +++++++++++++-- test/runtests.jl | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index b6d659fc7..d8223543f 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -823,15 +823,26 @@ if VERSION < v"0.5.0-dev+2228" end -if VERSION < v"0.5.0-dev+1182" - # Pull Request https://github.com/JuliaLang/julia/pull/13232 + +# Pull Request https://github.com/JuliaLang/julia/pull/13232 +# Rounding and precision functions: + +if VERSION >= v"0.5.0-dev+1182" + import Base: + setprecision, setrounding, rounding + +else # if VERSION < v"0.5.0-dev+1182" + export setprecision export setrounding export rounding setprecision(f, ::Type{BigFloat}, prec) = with_bigfloat_precision(f, prec) setprecision(::Type{BigFloat}, prec) = set_bigfloat_precision(prec) + + # assume BigFloat if type not explicit: setprecision(prec) = setprecision(BigFloat, prec) + setprecision(f, prec) = setprecision(f, BigFloat, prec) Base.precision(::Type{BigFloat}) = get_bigfloat_precision() diff --git a/test/runtests.jl b/test/runtests.jl index d1d792951..6cb4dd52b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -803,6 +803,11 @@ setprecision(BigFloat, 100) do @test precision(a) == 100 end +setprecision(130) do + a = big(pi) + @test precision(a) == 130 +end + for T in (BigFloat, Float64) setrounding(T, RoundDown) @test rounding(T) == RoundDown