1e-17 is indistinguishable from mathematical zero if it's based on differences among numbers that are O(1).
julia> a = fill(total, 100); julia> sum(a)/100 == total false julia> sum(a)/100 - total -1.3877787807814457e-17 But this is off by only one ulp: julia> nextfloat(sum(a)/100) == total true So my advice is that you should write your algorithms in a manner that takes the realities of floating-point arithmetic into account. --Tim On Sunday, September 06, 2015 05:19:36 PM Diego Javier Zea wrote: > The returned value from std should be zero if all the values are equal > (since the distance between the mean and the values should be zero). > However, the returned value isn't zero: > > julia> total > 0.11008615848501174 > > julia> mean(Float64[total for i in 1:100]) > 0.11008615848501173 > > julia> std(Float64[total for i in 1:100]) > 1.3947701538996772e-17 > > julia> std(Float64[total for i in 1:100]) ≈ zero(Float64) > false > > julia> mean(Float64[total for i in 1:100]) ≈ total > true > > > How can I get a more precise result from *std()*? > > Best,
