Skip to content

Commit e9fc79a

Browse files
authored
Work around rounding errors in nightly test (#248)
This forces the `BigFloat`-->`Float16` conversion to go through `Float32` instead of `Float64`.
1 parent bd00dfc commit e9fc79a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/normed.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ end
227227
T = rawtype(N)
228228
float_err = zero(Tf)
229229
for i = typemin(T):typemax(T)
230-
f_expected = Tf(i / BigFloat(FixedPointNumbers.rawone(N)))
230+
b_expected = i / BigFloat(FixedPointNumbers.rawone(N))
231+
f_expected = Tf(promote_type(Tf, Float32)(b_expected)) # workaround for issue #246
231232
isinf(f_expected) && break # for Float16(::Normed{UInt16,1})
232233
f_actual = Tf(reinterpret(N, i))
233234
float_err += abs(f_actual - f_expected)
@@ -238,7 +239,8 @@ end
238239
T = rawtype(N)
239240
error_count = 0
240241
for i in vcat(T(0x00):T(0xFF), (typemax(T)-0xFF):typemax(T))
241-
f_expected = Tf(i / BigFloat(FixedPointNumbers.rawone(N)))
242+
b_expected = i / BigFloat(FixedPointNumbers.rawone(N))
243+
f_expected = Tf(promote_type(Tf, Float32)(b_expected)) # workaround for issue #246
242244
isinf(f_expected) && break # for Float16() and Float32()
243245
f_actual = Tf(reinterpret(N, i))
244246
f_actual == f_expected && continue

0 commit comments

Comments
 (0)