That seems like a bug. Running something like, x = rand(Float16, 10, 10) y = rand(Float16, 10, 10) all(abs(x - y) .> eps(max(maximum(x), maximum(y))))
Gives me a true more than 80% of the time. -- John On Dec 14, 2014, at 3:26 AM, Steve Cordwell <[email protected]> wrote: > Hi, > > I have been playing around with Float16 arrays and I haven't been able to > figure out what is going on in this case, and whether it is expected > behaviour. According to the Wikipedia article half precision floating point > numbers are used for data storage and not for computations. > > I was surprised to find that > > > using Base.Test > > @test_approx_eq rand(Float16, 10,10) rand(Float16, 10, 10) > > gave no error, or even > > > @test_approx_eq 1000rand(Float16, 10,10) 1000rand(Float16, 10, 10) > > gave no errors. Using the testing modules method of working out the tolerance > for comparison of the arrays gives > > > array_eps(a) = eps(float(maximum(x->(isfinite(x) ? abs(x) : oftype(x,NaN)), > > a))) > > va=rand(10,10,3); vb=rand(Float16, 10,10,3); > > 1E4*length(va)*max(array_eps(va), array_eps(vb)) > 1464.84375 > > So a tolerance of over 1000. Is this to be expected with Float16, or not?
