Reputation: 3899
I am following along the "Julia Language Documentation Release 0.5.0-dev" and running some of their demo commands, this one is throwing an error. (reference page 28)
setrounding(BigFloat, RoundDown) do
BigFloat(1) + parse(BigFloat, "0.1")
end
throwing error:
ERROR: UndefVarError: setrounding not defined
but it does not seem like setrounding should be a variable, but a function.
Upvotes: 1
Views: 2198
Reputation: 5325
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}()
Upvotes: 2
Reputation: 2097
If you are working on v0.4, you need to look at the 0.4 docs, rather than the 0.5 docs that you are seeing. At the bottom right of the page, you will see a little black box with a green arrow. Click it, and select the version of the documentation you want.
In this particular case, the name of this function has changed between 0.4 (the latest release) and 0.5 (the current development).
Upvotes: 4