In Julia 0.4, there were two different functions, set_rounding
to change the rounding mode outright, and with_rounding
that you would use in the example you wrote, which changes the rounding mode only temporarily during the given function (in your case, the code in the do...end
block).
In Julia 0.5, these were merged into the single setrounding
function, that performs both of these tasks, and, in line with the tendency for functions in Base
, no longer has an underscore (_
).
The discussion about this renaming can be found in the original Pull Request: https://github.com/JuliaLang/julia/pull/13232
You can also use the new 0.5 syntax even in 0.4, by doing
using Compat
first; this is the Julia backwards-compatibility module, which in this case will define the setrounding
function with the correct behaviour. (You need a version of Compat
at least 0.7.11; if you have a previous version, just do a Pkg.update()
.)
e.g.
julia> using Compat
julia> setrounding(BigFloat, RoundDown) # 0.5 syntax
3
julia> get_rounding(BigFloat) # 0.4 syntax -- not advisable to mix these!
RoundingMode{:Down}()