Skip to content

Commit fee56cb

Browse files
Merge pull request #235 from araujoms/signs
Thank you. make sign preserve type
2 parents befa008 + 27aba8c commit fee56cb

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/math/prearith/prearith.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@inline signbit(a::DoubleFloat{T}) where {T} = signbit(HI(a))
2-
@inline sign(a::DoubleFloat{T}) where {T} = sign(HI(a))
2+
@inline sign(a::DoubleFloat{T}) where {T} = DoubleFloat{T}(sign(HI(a)))
33

44
@inline function (-)(a::DoubleFloat{T}) where {T<:IEEEFloat}
55
if iszero(LO(a)) || isnan(LO(a))

test/prearith.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
# @test ldexp(significand(val), exponent(val)) == val
2727

2828
@test signs(val) == (sign(HI(val)), sign(LO(val)))
29+
@test sign(val) === T(1)
30+
@test sign(negval) === T(-1)
2931
end
3032

3133
@testset "trunc $T" for T in (Double16, Double32, Double64)

0 commit comments

Comments
 (0)