Skip to content

Commit

Permalink
fix #8968: abs(big(-0.0))
Browse files Browse the repository at this point in the history
backport of a42a54b
  • Loading branch information
stevengj authored and tkelman committed Nov 18, 2014
1 parent ea4f2c9 commit 8425d55
Show file tree
Hide file tree
Showing 2 changed files with 4 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
3 changes: 3 additions & 0 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1827,3 +1827,6 @@ ndigf(n) = float64(log(float32(n)))
# issue #7911
@test sum([int128(1) int128(2)]) == int128(3)

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

0 comments on commit 8425d55

Please sign in to comment.