Skip to content

Commit

Permalink
Set isapprox default relative error to be the larger of the default…
Browse files Browse the repository at this point in the history
… relative errors of each type.
  • Loading branch information
simonbyrne committed Feb 29, 2016
1 parent 2ac9bc9 commit acbd169
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion base/floatfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const ≈ = isapprox
# default tolerance arguments
rtoldefault{T<:AbstractFloat}(::Type{T}) = sqrt(eps(T))
rtoldefault{T<:Real}(::Type{T}) = 0
rtoldefault{T<:Number,S<:Number}(x::Union{T,Type{T}}, y::Union{S,Type{S}}) = rtoldefault(promote_type(real(T),real(S)))
rtoldefault{T<:Number,S<:Number}(x::Union{T,Type{T}}, y::Union{S,Type{S}}) = max(rtoldefault(real(T)),rtoldefault(real(S)))

# fused multiply-add
fma_libm(x::Float32, y::Float32, z::Float32) =
Expand Down
8 changes: 4 additions & 4 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1663,10 +1663,10 @@ end
@test isnan(eps(-Inf))

@test .1+.1+.1 != .3
# TODO: uncomment when isapprox() becomes part of base.
# @test isapprox(.1+.1+.1, .3)
# @test !isapprox(.1+.1+.1-.3, 0)
# @test isapprox(.1+.1+.1-.3, 0, eps(.3))
@test isapprox(.1+.1+.1, .3)
@test !isapprox(.1+.1+.1-.3, 0)
@test isapprox(.1+.1+.1-.3, 0, atol=eps(.3))
@test isapprox(1.1,1.1f0)

@test div(1e50,1) == 1e50
@test fld(1e50,1) == 1e50
Expand Down

0 comments on commit acbd169

Please sign in to comment.