Just try it, it works!

julia> round(1.2345, 2)
1.23

You can check the possible versions of round() in the repl using methods():

julia> methods(round)
# 15 methods for generic function "round":
round(x::Integer) at int.jl:368
round(x::Float64) at float.jl:107
round(x::Rational{T<:Integer}) at rational.jl:164
round(x::Float32) at math.jl:297
round{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}) at sparse/sparsematrix.jl:431
round(M::SymTridiagonal{T}) at linalg/tridiag.jl:32
round(M::Tridiagonal{T}) at linalg/tridiag.jl:188
iround(M::Bidiagonal{T}) at linalg/bidiag.jl:67
round{T<:Real}(::AbstractArray{T<:Real,1}) at operators.jl:354
round{T<:Real}(::AbstractArray{T<:Real,2}) at operators.jl:355
round{T<:Real}(::AbstractArray{T<:Real,N}) at operators.jl:357
round(x::Float16) at float16.jl:101
round(x::BigFloat) at mpfr.jl:639
round(x,digits::Integer) at floatfuncs.jl:85
round(x,digits::Integer,base::Integer) at floatfuncs.jl:85

It's that second last one you want.  Unfortunately the list can get
quite long sometimes and it becomes hard to find what you're after.

~Chris


On Thu, Jun 5, 2014 at 4:06 PM, Hans W Borchers <[email protected]> wrote:
> I think I now understand the difference between rounding rules and rounding
> to
> integers as a mathematical function.
>
> Then, how can I in Julia round a number such as 0.025 to two decimal places
> and
> what will I get?  round() does not have a second parameter indicating the
> number
> of digits to round to like, e.g., round() in R has.  I tried to search
> through
> the Standard Library and did not see an obvious choice.
>

Reply via email to