Dear all,
In Matlab ,
>> round(2.5)
ans =
3
But in Julia,
julia> round(2.5)
2.0
If I want to get the same result which is from Matlab, how to write the code in Julia?
Dear all,
In Matlab ,
>> round(2.5)
ans =
3
But in Julia,
julia> round(2.5)
2.0
If I want to get the same result which is from Matlab, how to write the code in Julia?
julia> round(2.5, RoundNearestTiesAway)
3.0
see also: IEEE 754 - Wikipedia
Julia defaults to round ties to even. You can use round(x, RoundDown) to round to take the floor. The rounding modes are RoundDown,RoundNearestTiesUp,RoundUp,RoundFromZero,RoundNearestTiesAway, and RoundToZero
@Oscar_Smith @jling Thank you very much for both of your help.