Skip to content

Commit ad2cb25

Browse files
committed
return integer type with same precision
1 parent e5e57f6 commit ad2cb25

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

base/special/trig.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,10 @@ function cospi(x::T) where T<:Union{Integer,Rational}
860860
end
861861
end
862862

863-
sinpi(x::Integer) = 0
864-
cospi(x::Integer) = isodd(x) ? -1 : 1
863+
sinpi(x::T) where {T<:Integer} = zero(signed(T))
864+
sinpi(x::Bool) = 0
865+
cospi(x::T) where {T<:Integer} = isodd(x) ? one(signed(T)) : -one(signed(T))
866+
cospi(x::Bool) = x ? -1 : 1
865867
sinpi(x::Real) = sinpi(float(x))
866868
cospi(x::Real) = cospi(float(x))
867869

0 commit comments

Comments
 (0)