Skip to content

Commit 92a9378

Browse files
committed
handle precision better
Trust the precision of `accurate` is great enough, unless it's one of the known-imprecise types.
1 parent a95af77 commit 92a9378

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/testhelpers/ULPError.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ module ULPError
2525
end
2626
end
2727
end
28-
acc = Float64(accurate)::Float64
28+
acc = if accurate isa Union{Float16, Float32}
29+
# widen for better accuracy when doing so does not impact performance too much
30+
widen(accurate)
31+
else
32+
accurate
33+
end
2934
abs(Float32((approximate - acc) / eps(approximate))::Float32)
3035
end
3136
function ulp_error(accurate::Acc, approximate::App, x::AbstractFloat) where {Acc, App}

0 commit comments

Comments
 (0)