Float64 but with single precision

Sorry for the question which might look a bit stupid. I am preparing an example to show that certain numerical methods are unstable. To do this, I would need a method to use a Float64 number but, for the example, I would like to have an accuracy of only order 10^(-6). Do you know how to do that?

1 Like

Check out the ArbNumerics.jl package.

using ArbNumerics

function with_arbitrary(x::Float64)
    arbx = ArbFloat(x, digits=10)
    arbx + 1.0
end

sqrt(2.0) + 1.0 # 2.414213562373095....
with_arbitrary(sqrt(2.0)) # 2.414213562
1 Like