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 Mar 1, 2016
1 parent dceac08 commit afa0e53
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 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/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,19 +387,19 @@ j33 = besselj(3,3.)
@test besselj(-3,-3) == j33
@test besselj(-3,3) == -j33
@test besselj(3,-3) == -j33
@test besselj(3,3f0) Float32(j33)
@test besselj(3,3f0) j33
@test besselj(3,complex(3.)) j33
@test besselj(3,complex(3f0)) Float32(j33)
@test besselj(3,complex(3f0)) j33
@test besselj(3,complex(3)) j33

j43 = besselj(4,3.)
@test besselj(4,3) == j43
@test besselj(-4,-3) == j43
@test besselj(-4,3) == j43
@test besselj(4,-3) == j43
@test besselj(4,3f0) Float32(j43)
@test besselj(4,3f0) j43
@test besselj(4,complex(3.)) j43
@test besselj(4,complex(3f0)) Float32(j43)
@test besselj(4,complex(3f0)) j43
@test besselj(4,complex(3)) j43

@test_approx_eq j33 0.30906272225525164362
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 afa0e53

Please sign in to comment.