Created
May 5, 2017 15:14
-
-
Save simonbyrne/6dcfac9488a44f1fb2a64b82c01e88cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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