Skip to content

Commit

Permalink
fix #8968: abs(big(-0.0))
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Nov 10, 2014
1 parent 43967f5 commit a42a54b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/number.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ last(x::Number) = x
divrem(x,y) = (div(x,y),rem(x,y))
signbit(x::Real) = x < 0
sign(x::Real) = ifelse(x < 0, oftype(x,-1), ifelse(x > 0, one(x), x))
abs(x::Real) = ifelse(x < 0, -x, x)
abs(x::Real) = ifelse(signbit(x), -x, x)
abs2(x::Real) = x*x
copysign(x::Real, y::Real) = ifelse(signbit(x)!=signbit(y), -x, x)

Expand Down
4 changes: 4 additions & 0 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2030,3 +2030,7 @@ end
@test_throws InexactError convert(Int, big(2)^100)
@test_throws InexactError convert(Int16, big(2)^100)
@test_throws InexactError convert(Int, typemax(UInt))

let x = big(-0.0)
@test signbit(x) && !signbit(abs(x))
end

0 comments on commit a42a54b

Please sign in to comment.