Skip to content

Instantly share code, notes, and snippets.

@simonbyrne
Created May 5, 2017 15:14
Show Gist options
  • Save simonbyrne/6dcfac9488a44f1fb2a64b82c01e88cb to your computer and use it in GitHub Desktop.
Save simonbyrne/6dcfac9488a44f1fb2a64b82c01e88cb to your computer and use it in GitHub Desktop.
const HI = prevfloat(log10(prevfloat(Inf)))
function test(n)
xx = 0.0
zz = 0.0
for i = 1:n
x = reinterpret(Float64, rand(reinterpret(UInt64, 1e-18):reinterpret(UInt64, HI)))
if rand(Bool)
x = -x
end
bx = big(x)
y = exp10(x)
by = exp10(bx)
z = Float64(abs(y-by)/eps(y))
if z > zz
zz = z
xx = x
end
end
return (xx, zz)
end
@time xx, zz = test(1_000_000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment