Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

julia/Float: x == 0 -> iszero(x) #1870

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/julia/Float.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ divexact(a::Rational{T}, b::AbstractFloat; check::Bool=true) where T <: Union{Si
divexact(a::Rational{BigInt}, b::BigFloat; check::Bool=true) = a/b

function divides(a::BigFloat, b::BigFloat)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off-topic, but: why do we define this only for BigFloat, not for AbstractFloat? (or alternatively, why do we define this at all... but I guess that ship has sailed sigh)

if b == 0
if iszero(b)
return false, BigFloat(0)
else
return true, divexact(a, b; check=false)
Expand All @@ -109,7 +109,7 @@ end
###############################################################################

function gcd(a::T, b::T) where T <: AbstractFloat
if a == 0 && b == 0
if iszero(a) && iszero(b)
return T(0)
else
return T(1)
Expand All @@ -123,7 +123,7 @@ end
###############################################################################

function ppio(a::T, b::T) where T <: AbstractFloat
if a == 0 && b == 0
if iszero(a) && iszero(b)
return T(0), T(0)
else
return T(1), a
Expand Down
Loading