How to round 1.653782960785311e14 to 1.65e14?


#1

`julia> a
1.653782960785311e14

julia> round(a,2)
1.653782960785311e14
`
how to round 1.653782960785311e14 to 1.66e14 ?
Paul


#2
signif(1.653782960785311e14,3)

#3

That reads as “sign if” to me.


#4

Thanks, For all array not works , is something for array ?
Like:

signif(rand(5),3)
ERROR: MethodError: no method matching signif(::Array{Float64,1}, ::Int64)
Closest candidates are:
signif(::Real, ::Integer) at floatfuncs.jl:136
signif(::Real, ::Integer, ::Integer) at floatfuncs.jl:136
paul
W dniu 2018-03-27 o 21:56, Simon Byrne pisze:


#5

try signif.(rand(5),3))
which will boadcast the operation


#6

Same here :wink: so much for terse function names…


#7

+1

Can someone translate how I should read it correctly? Why it isn’t round?


#8

I guess we pronounce it as signif-icant.

help?> signif
search: signif significand signbit

  signif(x, digits, [base])

  Rounds (in the sense of round) x so that there are digits significant digits, under a base base representation, default 10.
  E.g., signif(123.456, 2) is 120.0, and signif(357.913, 4, 2) is 352.0.


#9

signif is too short, better is sigdigits [sigdigs if you must])


#10

“signif” is what R calls it, fwiw: https://stat.ethz.ch/R-manual/R-devel/library/base/html/Round.html


#11

its worth very little to those of us who are pleased to have let go of R :grinning:

(glad you are around, Harlan)


#12

It probably should be a method of round if someone wants to open an issue.


#13