From 88447683c15b0faadc251095f849066a937ca58d Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Sat, 27 Jul 2024 09:01:14 -0400 Subject: [PATCH 1/2] use iszero in isinteger(::AbstractFloat) --- base/floatfuncs.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/floatfuncs.jl b/base/floatfuncs.jl index a2a0f60bcf399..3d81c4e7db590 100644 --- a/base/floatfuncs.jl +++ b/base/floatfuncs.jl @@ -42,7 +42,7 @@ it is the minimum of `maxintfloat(T)` and [`typemax(S)`](@ref). maxintfloat(::Type{S}, ::Type{T}) where {S<:AbstractFloat, T<:Integer} = min(maxintfloat(S), S(typemax(T))) maxintfloat() = maxintfloat(Float64) -isinteger(x::AbstractFloat) = (x - trunc(x) == 0) +isinteger(x::AbstractFloat) = iszero(x - trunc(x)) # note: x == trunc(x) would fail for x=Inf # See rounding.jl for docstring. From 982e8d4a3fee66f116adc5088709d6b54a497f8e Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Sat, 27 Jul 2024 16:37:41 -0400 Subject: [PATCH 2/2] Update base/floatfuncs.jl Co-authored-by: Sukera <11753998+Seelengrab@users.noreply.github.com> --- base/floatfuncs.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/floatfuncs.jl b/base/floatfuncs.jl index 3d81c4e7db590..67e7899b4107c 100644 --- a/base/floatfuncs.jl +++ b/base/floatfuncs.jl @@ -42,7 +42,7 @@ it is the minimum of `maxintfloat(T)` and [`typemax(S)`](@ref). maxintfloat(::Type{S}, ::Type{T}) where {S<:AbstractFloat, T<:Integer} = min(maxintfloat(S), S(typemax(T))) maxintfloat() = maxintfloat(Float64) -isinteger(x::AbstractFloat) = iszero(x - trunc(x)) # note: x == trunc(x) would fail for x=Inf +isinteger(x::AbstractFloat) = iszero(x - trunc(x)) # note: x == trunc(x) would be incorrect for x=Inf # See rounding.jl for docstring.