Skip to content

Commit c7e7122

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

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
@@ -217,7 +217,8 @@ end
217217
T = rawtype(N)
218218
float_err = 0.0
219219
for i = typemin(T):typemax(T)
220-
f_expected = Tf(i / BigFloat(FixedPointNumbers.rawone(N)))
220+
b_expected = i / BigFloat(FixedPointNumbers.rawone(N))
221+
f_expected = Tf(promote_type(Tf, Float32)(b_expected)) # workaround for issue #246
221222
isinf(f_expected) && break # for Float16(::Normed{UInt16,1})
222223
f_actual = Tf(reinterpret(N, i))
223224
float_err += abs(f_actual - f_expected)
@@ -228,7 +229,8 @@ end
228229
T = rawtype(N)
229230
error_count = 0
230231
for i in vcat(T(0x00):T(0xFF), (typemax(T)-0xFF):typemax(T))
231-
f_expected = Tf(i / BigFloat(FixedPointNumbers.rawone(N)))
232+
b_expected = i / BigFloat(FixedPointNumbers.rawone(N))
233+
f_expected = Tf(promote_type(Tf, Float32)(b_expected)) # workaround for issue #246
232234
isinf(f_expected) && break # for Float16() and Float32()
233235
f_actual = Tf(reinterpret(N, i))
234236
f_actual == f_expected && continue

0 commit comments

Comments
 (0)