Friday 22 January 2016

Julia: eps(): Get distance between adjacent floating point numbers

‘eps()’ method available in two forms.

Method
Description
eps()
Returns the distance between 1.0 and the next larger representable floating-point value of Float64.
eps(x)
Returns the distance between 1 and the next larger representable floating-point value of the same data type as x.

julia> eps()
2.220446049250313e-16

julia> eps(2.3)
4.440892098500626e-16

julia> eps(2.9)
4.440892098500626e-16

julia> eps(15.4)
1.7763568394002505e-15


As you observe above snippet, the distance between two adjacent floating point numbers is not same, it is smaller for smaller values and larger for larger values.





Previous                                                 Next                                                 Home

No comments:

Post a Comment