Skip to content

Commit c6c6842

Browse files
committed
Merge pull request #15290 from JuliaLang/sb/isapprox
Set `isapprox` default relative error to be the larger of the default relative errors of each type.
2 parents 0b6cab6 + afa0e53 commit c6c6842

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

base/floatfuncs.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ const ≈ = isapprox
176176
# default tolerance arguments
177177
rtoldefault{T<:AbstractFloat}(::Type{T}) = sqrt(eps(T))
178178
rtoldefault{T<:Real}(::Type{T}) = 0
179-
rtoldefault{T<:Number,S<:Number}(x::Union{T,Type{T}}, y::Union{S,Type{S}}) = rtoldefault(promote_type(real(T),real(S)))
179+
rtoldefault{T<:Number,S<:Number}(x::Union{T,Type{T}}, y::Union{S,Type{S}}) = max(rtoldefault(real(T)),rtoldefault(real(S)))
180180

181181
# fused multiply-add
182182
fma_libm(x::Float32, y::Float32, z::Float32) =

test/math.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -387,19 +387,19 @@ j33 = besselj(3,3.)
387387
@test besselj(-3,-3) == j33
388388
@test besselj(-3,3) == -j33
389389
@test besselj(3,-3) == -j33
390-
@test besselj(3,3f0) Float32(j33)
390+
@test besselj(3,3f0) j33
391391
@test besselj(3,complex(3.)) j33
392-
@test besselj(3,complex(3f0)) Float32(j33)
392+
@test besselj(3,complex(3f0)) j33
393393
@test besselj(3,complex(3)) j33
394394

395395
j43 = besselj(4,3.)
396396
@test besselj(4,3) == j43
397397
@test besselj(-4,-3) == j43
398398
@test besselj(-4,3) == j43
399399
@test besselj(4,-3) == j43
400-
@test besselj(4,3f0) Float32(j43)
400+
@test besselj(4,3f0) j43
401401
@test besselj(4,complex(3.)) j43
402-
@test besselj(4,complex(3f0)) Float32(j43)
402+
@test besselj(4,complex(3f0)) j43
403403
@test besselj(4,complex(3)) j43
404404

405405
@test_approx_eq j33 0.30906272225525164362

test/numbers.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1663,10 +1663,10 @@ end
16631663
@test isnan(eps(-Inf))
16641664

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

16711671
@test div(1e50,1) == 1e50
16721672
@test fld(1e50,1) == 1e50

0 commit comments

Comments
 (0)