mirror of
https://github.com/tgorordo/WignerSymbols.jl.git
synced 2026-06-05 15:42:15 -07:00
improve speed of conversion from halfinteger to integer
This commit is contained in:
parent
ba3303cb68
commit
21688c9a2b
1 changed files with 3 additions and 1 deletions
|
|
@ -25,7 +25,9 @@ function Base.convert(::Type{HalfInteger}, r::Rational)
|
|||
end
|
||||
end
|
||||
Base.convert(::Type{HalfInteger}, r::Real) = convert(HalfInteger, convert(Rational, r))
|
||||
Base.convert(T::Type{<:Real}, s::HalfInteger) = convert(T, s.num//2)
|
||||
Base.convert(T::Type{<:Integer}, s::HalfInteger) = iseven(s.num) ? convert(T, s.num>>1) : throw(InexactError())
|
||||
Base.convert(T::Type{<:Rational}, s::HalfInteger) = convert(T, s.num//2)
|
||||
Base.convert(T::Type{<:Real}, s::HalfInteger) = convert(T, s.num/2)
|
||||
Base.convert(::Type{HalfInteger}, s::HalfInteger) = s
|
||||
|
||||
Base.isinteger(a::HalfInteger) = iseven(a.num)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue