WignerSymbols.jl/test
Morten Piibeleht 6ddbd340b0 Make convert(Real, ::HalfInteger) yield HalfInteger (#5)
As HalfInteger <: Real, there should be no reason to convert anything in
this situation. It happens because the convert method resorts to Float64
as an intermediate value.

To still get conversion to floats, we can just dispatch on AbstractFloat
instead. However, it should be better to convert the numerator to T
first and then divide, so that we would not use a potentially lower
precision intermediate value.

This solves the problem where calling sum on an vector of HalfIntegers
yields a floating point value, even though there is no reason to convert
in the summation:

julia> sum([HalfInteger(1//2), HalfInteger(3//2)])
2.0

This is because there is an implicit convert(::Real) in the Base.add_sum
function. With this patch the sum call correctly yields a HalfInteger.

It also updates the tests related to HalfInteger convert methods:

 - Make sure that the convert tests also check types
 - Add a few tests for converting out of HalfInteger
2019-02-21 00:16:26 +01:00
..
halfinteger.jl Make convert(Real, ::HalfInteger) yield HalfInteger (#5) 2019-02-21 00:16:26 +01:00
runtests.jl Partially revamp the HalfInteger type (#4) 2019-01-10 21:50:46 +01:00